Code::Blocks Forums
User forums => Using Code::Blocks => Topic started by: NanoGoner on November 27, 2012, 07:46:46 pm
-
I have been trying to compile a C program using "//" for comments. The error message for the line
// 3d.c
is
"exected identifier or '(' before '/' token"
If I change the line to
/* 3d.c */
it compiles fine. Can anyone tell me what's going on??
-
There's no line comment in c.
-
There's no line comment in c.
This is partially true, because they are supported in C99 mode.
-
Thank you both. I presume by C99 mode you mean C++. Can you tell me how to switch modes. I can't find it in the manual.
-
Thank you both. I presume by C99 mode you mean C++. Can you tell me how to switch modes. I can't find it in the manual.
There's nothing in the code that wouldn't compile under C++
-
Well, if your code is C++, rename the file to cpp or cxx or cc, but "nothing in the code that wouldn't compile under C++" is not really the same.
If your code is C, that is iso9899:1990 unless you specify something different. In that case, it should be C90 and not something else. On the other hand, if you need C99 features, you must use a compiler that supports this language revision (not all do), and you must tell the compiler.
GCC supports C99 if you add -std=c99 to the command line.
Note that some broken compilers (such as Microsoft) support C++ comments despite not properly supporting C99. That's because they use the C++ compiler (with some tweaks) to compile C, which accidentially works, although it shouldn't.