警告如下
[Linker Warning] Public symbol '_ErrorMsgTable' defined in both module C:\CBUILDER6\PROJECTS\222\UNIT1.OBJ and C:\CBUILDER6\PROJECTS\222\UNIT2.OBJ
我写了一个测试用例
1.建立一个pub.h文件,内容如下
#ifndef __Pub__
#define __Pub__
typedef struct
{
char *RetCode;
char *ErrorMsg;
} Error_Msg_Table;
Error_Msg_Table ErrorMsgTable[] =
{
{
"111", "错误哦"
}
};
#endif
我是这样做的
1.建立2个窗体,unit1和unit2.
2.unit1.h中#include "pub.h" ,并在一个函数中这样使用, ErrorMsgTable[0].RetCode="111";
3.在unit2.cpp中包含unit1.h和unit2.h
然后编译,会出现上面的link 警告,为什么会重复呢?我不是在pub.h中使用了#ifndef __Pub__
#define __Pub__ 。。。这样的结构吗?应该不会重复的编译了啊?