1

我在使用-ansi -pedantic具有// Comment here. 为什么会这样?

'/' 标记之前的预期表达式

程序中的杂散“\ 347”

示例代码int someVariable = 0; // Some comment

我有很多很多这些错误,这是什么?

4

2 回答 2

10

C89 不支持 C++ 风格的注释。

于 2010-12-22T17:47:43.390 回答
4

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.

于 2010-12-22T18:21:08.933 回答