• ubuntu下编译时遇到的错误及解决方式


    1、错误展示:

    hangma@ubuntu:~/test/test/protest/stack_test$ gcc  -c my_stack.c -o my_stack.o
    In file included from /usr/include/stdio.h:34:0,
                     from my_stack.c:2:
    /usr/lib/gcc/i686-linux-gnu/4.7/include/stddef.h:213:9: error: expected ‘;’, identifier or ‘(’ before ‘unsigned’
    In file included from /usr/include/stdio.h:75:0,
                     from my_stack.c:2:
    /usr/include/libio.h:334:3: error: expected specifier-qualifier-list before ‘size_t’
    /usr/include/libio.h:366:62: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/libio.h:375:6: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/libio.h:497:19: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘_IO_sgetn’
    In file included from my_stack.c:2:0:
    /usr/include/stdio.h:320:35: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/stdio.h:326:47: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/stdio.h:338:20: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/stdio.h:345:10: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/stdio.h:387:44: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/stdio.h:391:45: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/stdio.h:663:11: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/stdio.h:666:9: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/stdio.h:676:8: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/stdio.h:706:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘fread’
    /usr/include/stdio.h:712:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘fwrite’
    /usr/include/stdio.h:734:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘fread_unlocked’
    /usr/include/stdio.h:736:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘fwrite_unlocked’
    In file included from my_stack.c:3:0:
    /usr/include/stdlib.h:140:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__ctype_get_mb_cur_max’
    In file included from my_stack.c:3:0:
    /usr/include/stdlib.h:337:4: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/stdlib.h:367:4: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/stdlib.h:471:22: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/stdlib.h:473:22: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/stdlib.h:473:38: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/stdlib.h:485:36: error: expected declaration specifiers or ‘...’ before ‘size_t’
    In file included from /usr/include/stdlib.h:497:0,
                     from my_stack.c:3:
    /usr/include/alloca.h:33:22: error: expected declaration specifiers or ‘...’ before ‘size_t’
    In file included from my_stack.c:3:0:
    /usr/include/stdlib.h:503:22: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/stdlib.h:508:45: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/stdlib.h:508:65: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/stdlib.h:756:9: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/stdlib.h:756:25: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/stdlib.h:761:34: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/stdlib.h:761:50: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/stdlib.h:840:6: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/stdlib.h:843:6: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/stdlib.h:847:31: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/stdlib.h:851:31: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/stdlib.h:860:38: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/stdlib.h:864:36: error: expected declaration specifiers or ‘...’ before ‘size_t’
    /usr/include/stdlib.h:871:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘mbstowcs’
    /usr/include/stdlib.h:874:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘wcstombs’
    my_stack.c: In function ‘CreateStack’:
    my_stack.c:24:16: warning: incompatible implicit declaration of built-in function ‘malloc’ [enabled by default]


    错误解决方式:

    将.c文件中的系统头文件放在自己写的头文件前边就可以了





    2、错误提示:

    hangma@ubuntu:~/test/test/protest/stack_test$ gcc  -c my_stack.c -o my_stack.o
    my_stack.c:7:1: error: expected ‘;’, identifier or ‘(’ before ‘int’


    错误解决:在我的头文件中,定义的结构体最后忘记加分号了


  • 相关阅读:
    Linux下Socket编程之地址结构
    矫正Fedora 8中livna源Nvidia驱动托付关连
    Firefox3 RC1颁布各种新特征发扬阐发更平定
    Fedora 8中完全开启compizfusion特效
    编译安置gsopcast SVN版
    Sopcast for linux更新至3.01!
    措置惩罚Fedora 8中的装备权限标题成绩
    vsftp假造用户设置(Ubuntu8.04)
    QQ2008贺岁版 on FedoraBy wine 0.9.58
    vFU NET
  • 原文地址:https://www.cnblogs.com/james1207/p/3278453.html
Copyright © 2020-2023  润新知