标签:std 失败 gcc 类型 error: hello return world int
#include <stdio.h>
void main(){
printf("hello world.\n");
}
gcc hello.c -o hello -std=c99
编译通过。
但通过如下编译则失败——
g++ hello.c -o hello -std=c++11
失败信息为:
hello.c:3:11: error: ‘::main’ must return ‘int’
void main()
^
这是因为在c+11中,main必须为int类型,但却可以不必有返回值;修改代码为如下即可——
#include <stdio.h>
int main(){
printf("hello world.\n");
/*return 0; 可以不需要这行*/
}
标签:std 失败 gcc 类型 error: hello return world int
原文地址:http://www.cnblogs.com/atoman/p/7374632.html