我在使用-ansi -pedantic
具有// Comment here
. 为什么会这样?
'/' 标记之前的预期表达式
程序中的杂散“\ 347”
示例代码int someVariable = 0; // Some comment
我有很多很多这些错误,这是什么?
C89 不支持 C++ 风格的注释。
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
.