main.cpp first defined here 解决

本文详细解析了在编程过程中遇到的'firstdefinedhere'错误的原因,并提供了有效的解决策略,帮助开发者识别并修复头文件中可能导致重复定义的问题,特别是针对静态变量的定义和初始化。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

main.cpp   first defined here 解决


作者Attilax ,  EMAIL:1466519819@qq.com 
来源:attilax的专栏
地址:http://blog.youkuaiyun.com/attilax


详细:/
//////////////
D:\qtworkspace\atiStar\main.cpp:29: error: first defined here


原因:
//////////
并非是main.cpp有错误,,而是上面的其他文件,特别是头文件也许有错误...重复定义错误..
特别是static 变量的定义初始化..


解决:
////////////
查看在的文件,修理重复定义错误..



0/2 /tmp/ccvhPFNh.o: In function `InitQueue(SqQueue&)': sqqueue.cpp:(.text+0x0): multiple definition of `InitQueue(SqQueue&)' /tmp/ccTCvRuh.o:main.cpp:(.text+0x192): first defined here /tmp/ccvhPFNh.o: In function `QueueEmpty(SqQueue)': sqqueue.cpp:(.text+0xc4): multiple definition of `QueueEmpty(SqQueue)' /tmp/ccTCvRuh.o:main.cpp:(.text+0x2f3): first defined here /tmp/ccvhPFNh.o: In function `EnQueue(SqQueue&, int)': sqqueue.cpp:(.text+0x187): multiple definition of `EnQueue(SqQueue&, int)' /tmp/ccTCvRuh.o:main.cpp:(.text+0x1e8): first defined here /tmp/ccvhPFNh.o: In function `DeQueue(SqQueue&, int&)': sqqueue.cpp:(.text+0x224): multiple definition of `DeQueue(SqQueue&, int&)' /tmp/ccTCvRuh.o:main.cpp:(.text+0x27b): first defined here /tmp/ccdwiTdi.o: In function `InitStack(SqStack&)': sqstack.cpp:(.text+0x0): multiple definition of `InitStack(SqStack&)' /tmp/ccTCvRuh.o:main.cpp:(.text+0x0): first defined here /tmp/ccdwiTdi.o: In function `StackEmpty(SqStack)': sqstack.cpp:(.text+0xb2): multiple definition of `StackEmpty(SqStack)' /tmp/ccTCvRuh.o:main.cpp:(.text+0x17b): first defined here /tmp/ccdwiTdi.o: In function `Push(SqStack&, int)': sqstack.cpp:(.text+0x11c): multiple definition of `Push(SqStack&, int)' /tmp/ccTCvRuh.o:main.cpp:(.text+0x57): first defined here /tmp/ccdwiTdi.o: In function `Pop(SqStack&, int&)': sqstack.cpp:(.text+0x1ea): multiple definition of `Pop(SqStack&, int&)' /tmp/ccTCvRuh.o:main.cpp:(.text+0x129): first defined here collect2: error: ld returned 1 exit status
06-30
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值