Kyl*_*lsh 1 c c++ gcc comments gcc4
我在Ubuntu 9.04 64位上使用GCC 4.3.3,并且在C代码中使用C++风格的注释会出错.当我在标题中说"默认"时,我的意思是简单地调用gcc test.c
根据GCC 4.3.3文档(这里),这是支持的...但我仍然得到了错误.
这些错误随着我的编译字符串添加了一个简单的-std = c99而消失了,所以我的问题就解决了.很奇怪,如果有任何GCC专家对此有解释,因为在我看来,这与文档明显矛盾.
#include <stdio.h>
// this is a comment
int main( void )
{
return 0;
}
Run Code Online (Sandbox Code Playgroud)
Ubuntu可能会覆盖默认值,应该是gnu89.当然,我不能用我的GCC 4.3副本(在Debian上)得到它.
% echo '// foo' | gcc-4.3 -x c -c -
% echo '// foo' | gcc-4.3 -std=gnu89 -x c -c -
% echo '// foo' | gcc-4.3 -std=c89 -x c -c -
<stdin>:1: error: expected identifier or '(' before '/' token
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
652 次 |
| 最近记录: |