Compiler CW6.0 as well as 6.3 for HCS08.
My question is: which standard, if any, does CW follow?
For this project, it is very important that my program is strictly confoming to the C standard ISO 9899:1990.
Now I've been trying out CW and I'm not quite sure which standard it follows, if any. According to compiler docs it follows "ANSI C", whatever that is. I have set "strict ANSI" in the compiler options.
As far as I know, ANSI C refers to an old C standard that was withdrawn 21 years ago in 1989. According to ANSI, there exists no such standard and they refer to ISO/IEC 9899:1999.
However, CW seems to allow some oddities from C99, such as complex numbers, struct initializing by member identfier (designated initializers), trailing comma at the end of an enumeration list, the register keyword, C++ comments etc. Yet it does not implement the whole C99 standard.
So which standard does it follow? Should "strict ANSI" be interpreted as "The Codewarrior-specific mix of C90 and C99 language"?
Is it possible in some way to enforce CW to follow a C standard? If not C99, then at least C90?
To mi knowledge the HC08 compiler is following the ISO 9899:1990 standard, it is not supporting C99.
> However, CW seems to allow some oddities from C99,
> such as complex numbers,
No, the HC08 compiler does not support complex numbers.
> struct initializing by member identfier (designated initializers),
Not supported either.
> trailing comma at the end of an enumeration list,
Not sure about this one.
> the register keyword
Are you sure register is not in C90? Out of my memory C90 did have the register keyword.
> , C++ comments etc
The HC08 compiler does not accept C++ comments when used with the -ANSI option, just checked.
> . Yet it does not implement the whole C99 standard
It does not support C99, hope it does not claim it does.
One thing which is confusing about the documentation is that the CF compiler and the HC08 compiler are quite a bit different. The CF compiler does support most (if not all) of the C99 features, it also offers a switch to enable or disable those separately.
Daniel
> To mi knowledge the HC08 compiler is following the ISO 9899:1990 standard, it is not supporting C99.
According to the help files as well as the link provided by Kef, it supports ANSI C (ANSI X3.159-1989, X3J11). This would be the draft standard made by the working group, which became obsolete in 1990. The differences between "ANSI C" and standard C are cosmetical (chapter enumeration, foreword etc), yet I find it odd that that they refer to a standard withdrawn 21 years ago.
Anyway, it clearly does -not- follow C89 nor C90, as it implements C99 features.
>> However, CW seems to allow some oddities from C99,
>> such as complex numbers,
>No, the HC08 compiler does not support complex numbers.
There is at least a h-file called <complex.h> that looks exactly like the one needed for C99, that comes with the compiler. I'm not sure if it works or not. Why does this h-file come with the compiler if it isn't supported?
>> struct initializing by member identfier (designated initializers),
> Not supported either.
Oops, I may have confused CW for HC08 with some other "ANSI C Codewarrior". I have five or so different Codewarriors in my machine, sorry if I may have got them mixed up. Maybe it is supported for Coldfire?
>> trailing comma at the end of an enumeration list,
> Not sure about this one.
Well, I am. This was detected by my static initializer but not by the CW compiler. This is a C99 feature.
> the register keyword
It may be true that this is actually C90.
Is there an option in CW to disable C99 features in CW HC08?
> Anyway, it clearly does -not- follow C89 nor C90, as it implements C99 features.
Supporting features which are in C99 but not in C90 does not imply that it does not adhere to the C90 standard.
C90 compliance depends on the C90 standard only, so the question for whatever topic is if C90 does require some topic or if it does forbid it.
This is a different question than if a program only relies on requirements guaranteed by the C90 standard.
>There is at least a h-file called <complex.h> that looks exactly like the one needed for C99, that comes with the compiler.
> I'm not sure if it works or not. Why does this h-file come with the compiler if it isn't supported?
I saw one c++ header called complex.h. But this header wont compile anyhow in C. While it is unfortunate to have this header file name collision, it does not violate any C standard compliance (well it will cause trouble if the compiler is going to support C99).
>>> trailing comma at the end of an enumeration list,
>> Not sure about this one.
> Well, I am. This was detected by my static initializer but not by the CW compiler. This is a C99 feature.
Either way, the compiler had this behavior long before 1999. You can file a service request to extend the compiler to warn about this when -ansi is present. But unless the C90 standard is not allowing the comma (I did not check), I would not consider it to be a compiler bug.
> Is there an option in CW to disable C99 features in CW HC08?
There is no option to disable C99 extensions because the compiler does not intentionally support any C99 feature. While the C++ comment and the comma might have been picked up by C99, the compiler did support those things before that standard was defined. And at least the C++ comments are not allowed when -ansi is used.
Daniel
If the C99 features break the C90 syntax rules, it does not conform to C90.
But maybe the trailing comma is the only issue after all. C90 explicitly bans trailing comma, as it is not present in the syntax rules for enumeration rules in C90 (and in C++), while it is there in C99. I will make a service request for this bug to be fixed.
Hello,
CompilerGuru wrote:
> the register keywordAre you sure register is not in C90? Out of my memory C90 did have the register keyword.
I just checked an old reference text book "ANSI C made easy" by Schildt, published in 1989, which presumably predates C1990. It does mention the register keyword. Maybe this keyword goes back to K & R?
Regards,
Mac
See in online help or in <CW root\help\pdf\Compiler_HC08.pdf ANSI-C Frontend->Implementation Features->Translation Limitations. As I understand it, comparison is made against ISO/IEC 9899:1990.
Shouldn't this be asked in Codewarrior forums?