We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I would like to request on the next update of the ARM tools that a check box be added to allow "// style comments". This has been added to the C99 standard. This way, Stict ANSCI C can be checked along with checking "//" style comments.
Thanks, Barry Gordon ================================================== The following statement was copied from david.tribble.com/.../cdiffs.htm
Comments C++ recognizes //... comments as well as /*...*/ comments. C90 only recognizes the /*...*/ form of comments. The //... form usually produces a syntax error in C90, but there are rare cases that may compile erroneously without warning: i = (x//*y*/z++ , w); C99 recognizes both forms of comments. [C99: §5.1.1.2, 6.4.9] [C++98: §2.1, 2.7]
Reinhard Keil said:
"The RealView [ARM] Compiler is ANSI C99. All other Keil Compilers are C90 with some language extensions."
See: http://www.keil.com/forum/docs/thread8500.asp
C51 certainly does allow the "//" comment style
I think Barry is referring to:
Project -> Options for Target -> 'C/C++' Tab 'Stict ANSI C' checkbox.
checking this Checkbox adds the '--strict' command to the compiler command string at the bottom.
From the \Keil\ARM\Hlp\RV_cc.pdf manual, page 42 of the PDF (2-24 of the manual)
Enables strict ISO mode (ISO/IEC 9899:1990 (E)) and the C++ Standard (ISO/IEC 14882:1998 (E)). Diagnostic messages are returned when nonstandard features are used, and features that conflict with ISO C or C++ are disabled. This is compatible in both C and C++ mode.
I forgot to indicate the C/C++ tab in the original post. When strict is selected error #29 "expected an expression" is output on a line suct as
int myVar = 10; // C99 style comment
then warnings and errors are output for other lines following. I've seen other compilers that allow '// style comment" with '--strict' enabled by providing an additional checkbox.
I just received an e-mail from keil support stating:
"Strict ISO C99 mode is planned to be added in RealView 3.1. This should be out sometime before midyear."
Oh I see - you want a "Strict, but with a weakness for '//' comments" option...?!
No, just strict 8-year old standard (C99), not an 18-year old standard (C90). I would even like a stricture standard that would produce an error if a logical statement did not evaluate to a bool that would catch an error such as
if (A = 3)
C# catches that one.
I would even like a stricture standard
Tools like Lint and the MISRA C coding rules exist for a reason. Go ahead and use them.
A compiler's task is to turn source code into executable code, not to find every possible flaw in it.