C语言编译器报错

[align=center][color=darkblue][b][u][size=xx-large]C语言编译器报错及其解决[/size][/u][/b]
[/color][/align]


编译器: TDM-GCC 4.7.1 32-bit
执行 gcc.exe...
gcc.exe "C:\Users\Administrator\Desktop\test1\2045.c" -o "C:\Users\Administrator\Desktop\test1\2045.exe" -m32 -g3 -I"F:\software(软件安装包)\Dev-cpp\MinGW64\x86_64-w64-mingw32\include" -L"F:\software(软件安装包)\Dev-cpp\MinGW64\x86_64-w64-mingw32\lib32" -static-libgcc -m32 -g3
In file included from f:\software(软件安装包)\dev-cpp\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/stddef.h:7:0,
from f:\software(软件安装包)\dev-cpp\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/include/stddef.h:1,
from D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/stdio.h:26,
from C:\Users\Administrator\Desktop\test1\2045.c:1:

f:\software(软件安装包)\dev-cpp\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/crtdefs.h:26:1: error: unknown type name 'size_t'
In file included from f:\software(软件安装包)\dev-cpp\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/stddef.h:7:0,
from f:\software(软件安装包)\dev-cpp\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/include/stddef.h:1,
from D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/stdio.h:26,
from C:\Users\Administrator\Desktop\test1\2045.c:1:
f:\software(软件安装包)\dev-cpp\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/crtdefs.h:183:5: error: unknown type name 'wchar_t'
In file included from f:\software(软件安装包)\dev-cpp\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/include/stddef.h:1:0,
from D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/stdio.h:26,
from C:\Users\Administrator\Desktop\test1\2045.c:1:
f:\software(软件安装包)\dev-cpp\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/stddef.h:20:19: error: expected ',' or ';' before '_set_errno'
f:\software(软件安装包)\dev-cpp\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/stddef.h:21:19: error: expected ',' or ';' before '_get_errno'
f:\software(软件安装包)\dev-cpp\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/stddef.h:26:36: error: expected ',' or ';' before '__threadhandle'
f:\software(软件安装包)\dev-cpp\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.1/../../../../x86_64-w64-mingw32/include/stddef.h:218:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'typedef'

In file included from C:\Users\Administrator\Desktop\test1\2045.c:1:0:
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/stdio.h:191:65: error: unknown type name 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/stdio.h:202:55: error: unknown type name 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/stdio.h:206:56: error: unknown type name 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/stdio.h:216:46: error: unknown type name 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/stdio.h:217:48: error: unknown type name 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/stdio.h:297:40: error: expected ',' or ';' before 'fread'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/stdio.h:298:40: error: expected ',' or ';' before 'fwrite'
In file included from C:\Users\Administrator\Desktop\test1\2045.c:1:0:
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/stdio.h:446:59: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/stdio.h:450:60: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/stdio.h:480:52: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/stdio.h:482:25: error: expected declaration specifiers or '...' before 'size_t'
In file included from C:\Users\Administrator\Desktop\test1\2045.c:2:0:
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:36:65: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:37:72: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:38:68: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:39:68: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:40:59: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:46:40: error: expected ',' or ';' before 'strcspn'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:49:40: error: expected ',' or ';' before 'strlen'

D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:50:68: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:51:72: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:52:68: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:55:40: error: expected ',' or ';' before 'strspn'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:58:40: error: expected ',' or ';' before 'strxfrm'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:65:74: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:66:74: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:72:74: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:73:61: error: expected declaration specifiers or '...' before 'size_t'

D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:77:65: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:80:74: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:81:75: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:90:73: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:91:72: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:101:73: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:102:84: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:104:54: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:106:60: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:111:64: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:127:40: error: expected ',' or ';' before 'wcscspn'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:129:40: error: expected ',' or ';' before 'wcslen'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:130:77: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:131:77: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:132:76: error: expected declaration specifiers or '...' before 'size_t'

D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:135:40: error: expected ',' or ';' before 'wcsspn'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:138:40: error: expected ',' or ';' before 'wcsxfrm'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:152:80: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:153:71: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:159:80: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:160:82: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:177:79: error: expected declaration specifiers or '...' before 'size_t'
D:\SoftwareDeveloping\eclipse_cpp\MinGW\include/string.h:178:70: error: expected declaration specifiers or '...' before 'size_t'
C:\Users\Administrator\Desktop\test1\2045.c: In function 'mian':
C:\Users\Administrator\Desktop\test1\2045.c:7:3: warning: incompatible implicit declaration of built-in function 'memset' [enabled by default]

执行结束




[size=x-large][b][color=red][table]
|悲剧啊| main竟然写成了mian 。但是编译却不会直接报错,报了一些莫名其妙的东西出来。
|IDE的好处|增加开发效率
|不好之处|增强了开发人员对其依赖。
[/table][/color][/b][/size]

[table]
|说明|[url=http://bai-du-bai-du123.iteye.com/admin/blogs/new]本文为原创,转载请注明出处。[/url]
|Author|[url=http://bai-du-bai-du123.iteye.com/admin/blogs/new]skywolf[/url]
[/table]
### C语言编译器中 "unresolved symbols" 错误的原因及解决方法 在C语言开发过程中,遇到 `unresolved symbols` 的错误通常意味着链接阶段出现问题。这种错误表明某些函数或变量声明存在,但在最终链接时未能找到其定义。 #### 原因分析 1. **未实现的函数或变量** 如果程序中调用了某个函数或访问了某个全局变量,但这些函数或变量并未提供具体实现,则会出现此错误。例如,在头文件中声明了一个函数原型却忘记在源文件中实现它[^2]。 2. **缺少库文件链接** 当使用标准库或其他第三方库中的功能时,如果未正确指定所需的动态或静态库路径以及名称,也会引发此类问题。比如尝试调用数学库中的 `ceil()` 函数而未链接 `-lm` 数学库的情况。 3. **多文件项目管理不当** 对于涉及多个 `.c` 文件的大规模工程来说,可能由于部分对象文件(.o 或 .obj)被遗漏而导致无法解析跨模块间共享的数据项或子程序接口[^3]。 4. **宏替换引起的冲突** 宏定义可能会无意间改变实际传递给编译系统的参数列表形式,从而影响到外部依赖关系的确立过程[^1]。 #### 解决方案 针对上述几种情况分别给出对应的处理办法如下: - 确认所有已声明的内容均有相应的实体支持;即检查每一个extern关键字修饰的对象是否都有明确的位置存放它们的实际值。 - 添加必要的命令行选项来指示哪些附加资源应该参与到构建流程当中去。对于Linux下的gcc/g++工具链而言,可以通过加上像-l这样的标记告诉系统去哪里寻找特定类型的辅助材料。例如要加入Math Library的支持就需要写成这样:`gcc test.c -o outputfile -lm` - 在IDE环境下(如Visual Studio, Code::Blocks),通过设置属性页里的Linker->Input字段添加额外输入项;而在Makefiles或者其他自动化脚本里则需相应调整规则描述语句以包含完整的构件集合。 - 调整预处理器指令的应用方式避免不必要的副作用发生。仔细审查那些可能导致意外行为变化的地方并作出适当修正。 下面是一个简单的例子展示如何正确引入外部符号: ```c // myheader.h #ifndef MYHEADER_H_ #define MYHEADER_H_ int addNumbers(int a,int b); #endif /*MYHEADER_H_*/ // main.c #include <stdio.h> #include "myheader.h" void main(){ printf("%d",addNumbers(5,7)); } // implementation.c #include "myheader.h" int addNumbers(int a , int b){ return (a+b); } ``` 当单独编译这两个`.c`文件之后再进行连接操作就不会碰到找不到symbol的问题了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值