作者johnjohnlin (LYSin8)
看板EE_DSnP
标题[问题] "multiple definition" compile error
时间Tue Jan 4 21:29:05 2011
嗯...原则上是
在教授提供的 parseError() 下面有一个 case
case REDEF_GATE:
<< errGate.getTypeStr() << " in line " << errGate.getLineNo()
他要用到 getTypeStr(),好像没有定义
所以我就在 cirgate.cpp cirgate.h 照正常步骤加入了定义
可是 compile 起来就出现了
../../lib/libcir.a(cirSim.o):(.data+0x0): multiple definition of `gateTypeStr'
../../lib/libcir.a(cirCmd.o):(.data+0x0): first defined here
ld returned 1 exit status
这是为什麽呢?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.243.89
1F:推 tomap41017:感觉是老师有定义但你又重新定义一份,找一下在哪吧.. 01/04 21:53
2F:→ johnjohnlin:我没定义的时候 compile 会出现 undefine error...... 01/04 22:03
3F:推 ric2k1:可以说明一下你是怎麽定义的吗? 01/04 22:07
4F:→ johnjohnlin:在 class CirAigGate 的 public 下加入 01/04 22:20
5F:→ johnjohnlin:const char* getTypeStr(); int getLineNo (); 两行 01/04 22:20
6F:→ johnjohnlin:然後在 CirGate.cpp 中加入函数内容的定义 01/04 22:21
7F:推 ric2k1:你是不是有 .h 档没有定义好 "#idndef ..."? 01/04 23:09
8F:→ johnjohnlin:可是那个不是 macro 吧?应该是 member function? 01/04 23:28
9F:推 singerlibra:"get"和"gate"的误植吗? 01/05 00:11
10F:→ johnjohnlin:咦,可是是那个是变数名,不是函数名... 01/05 00:29
11F:→ johnjohnlin:还是是因为我把 string 改成 char* 的关系? 01/05 00:30
12F:→ johnjohnlin:加了 static 就好了耶...? 01/05 00:33