编译简单的东西时
inline int test() { return 3; }
int main()
{
test();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
用gcc -c test.c,一切顺利.如果-ansi添加了关键字,gcc -ansi -c test.c则会收到错误消息
test.c:1:8: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘int’
Run Code Online (Sandbox Code Playgroud)
即使明确选择了C99标准,也是如此gcc -std=c99 -ansi -c test.c.
这是什么原因,是否有推荐的修复?
Ree*_*sey 15
你需要使用:
gcc -std=c99 -c test.c
Run Code Online (Sandbox Code Playgroud)
-ansi选项等效于-std = c90.
ANSI C实际上是C的1990版本,它不包含inline关键字.