我寫一個簡單的.c文件和編譯我的Sesu11.But它有很多的錯誤,即使它只是包括被它引起的一種簡單的printf sentence.I奇蹟我的編譯環境不正確以及如何檢查我的環境。謝謝。 這是我的C代碼和編譯結果。一個簡單的C代碼,但是編譯生成許多錯誤在SUSE
[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’
看起來您的gcc安裝有問題。頭文件和編譯器似乎在您的平臺上不兼容。 –
您的/usr/include/libio.h或/usr/include/stdio.h是否損壞? – immibis
你也應該使用int main(void) –