我写了一个简单的.c文件并在Sesu11中编译了它。但是它有很多错误,即使它只是包含了一个简单的printf语句。我想知道这是因为我的编译环境不正确以及如何检查我的环境造成的。谢谢。
这是我的C代码和编译结果。
[Linux:/si/usr/hrl]vi hello.c
#include <stdio.h>
int main()
{
printf("hello world!");
return 0;
}
[Linux:/si/usr/hrl]gcc -O hello.c -o hello
In file included from /usr/include/stdio.h:37,
from hello.c:1:
/usr/lib64/gcc/x86_64-suse-linux/4.3/include/stddef.h:214: error:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘typedef’
In file included from /usr/include/stdio.h:78,
from hello.c:1:
/usr/include/libio.h:332: error:expected specifier-qualifier-list before ‘size_t’
/usr/include/libio.h:364: error:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/libio.h:373: error:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/libio.h:495: error:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘_IO_sgetn’
In file included from hello.c:1:
/usr/include/stdio.h:301: error:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdio.h:307: error:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdio.h:319: error:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdio.h:326: error:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdio.h:368: error:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdio.h:370: error:格式字符串实参不是字符串型
/usr/include/stdio.h:372: error:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdio.h:374: error:格式字符串实参不是字符串型
/usr/include/stdio.h:644: error:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdio.h:647: error:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdio.h:657: error:expected declaration specifiers or ‘...’ before ‘size_t’
/usr/include/stdio.h:687: error:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘fread’
/usr/include/stdio.h:693: error:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘fwrite’
/usr/include/stdio.h:715: error:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘fread_unlocked’
/usr/include/stdio.h:717: error:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘fwrite_unlocked’
最佳答案
您的头文件似乎已损坏。既然您使用的是Suse,我建议您先删除然后重新安装devel_basis
:
zypper remove devel_basis
zypper install devel_basis
你应该没事的!
关于c - 一个简单的C代码但编译会在Suse中产生许多错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34938254/