/tmp/ccTEUgva.o:(.data+0x0): multiple definition of `a'

本文详细解释了在编程过程中遇到不同.c文件中定义同名变量时,如何通过编译和链接过程导致的错误,并提供了解决方案。包括使用作用域修饰符、命名空间或全局变量隔离等方法来避免此类问题。

出现这种情况很可能是因为你在不同的.c文件中定义了同一名字的变量,并且同时编译。这时报的是链接错误,即程序不知道使用哪一个

变量。。。

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

帅气的东哥

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值