一个简单的C代码,但编译在Suse中生成许多错误

时间:2016-01-22 02:59:35

标签: c suse

我写了一个简单的.c文件并在我的Sesu11中编译它。但它有很多错误,即使它只包含一个简单的printf语句。我想知道这是由于我的编译环境不正确以及如何检查我的environment.Thanks。 这是我的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’

1 个答案:

答案 0 :(得分:0)

您的标头文件似乎已损坏。由于您使用的是Suse,我建议您删除然后重新安装devel_basis

 zypper remove devel_basis
 zypper install devel_basis

之后你应该没事!