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’


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


GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐