Reputation: 1202
I'm getting errors while compiling with -ansi -pedantic
on lines that have // Comment here
. Why does this happen?
expected expression before '/' token
stray '\347' in program
Example code int someVariable = 0; // Some comment
I have many many errors of these, what is it?
Upvotes: 1
Views: 1298
Reputation: 215259
Because the gcc developers are mistaken about what ANSI C
means, or kept the option aligned to an old standard for "compatibility". ANSI C is ISO C is C99, which allows //
comments, but when many people say ANSI C
they mean "the first standardization of the C language by ANSI", i.e. C89. The gcc -ansi
option is equivalent to -std=c89
.
If you're trying to enforce conformance to modern standards, you should use -std=c99
instead of -ansi
.
Upvotes: 4