程序中有一些全局变量,我把他们放在一个头文件中:global.h
#ifndef GLOBAL_H
#define GLOBAL_HSOCKET g_srvSocket;CPtrList g_threadList;...#endif
然后在其他cpp文件中为了引用这些全局变量,包含了头文件global.h比如在ServerDlg.cpp中:#include "global.h"结果报错:Linking...
global.obj : error LNK2005: "unsigned int g_srvSocket" (?g_srvSocket@@3IA) already defined in ServerDlg.objglobal.obj : error LNK2005: "class CPtrList g_threadList" (?g_threadList@@3VCPtrList@@A) already defined in ServerDlg.obj....
#ifndef GLOBAL_H
#define GLOBAL_HSOCKET g_srvSocket;CPtrList g_threadList;...#endif
然后在其他cpp文件中为了引用这些全局变量,包含了头文件global.h比如在ServerDlg.cpp中:#include "global.h"结果报错:Linking...
global.obj : error LNK2005: "unsigned int g_srvSocket" (?g_srvSocket@@3IA) already defined in ServerDlg.objglobal.obj : error LNK2005: "class CPtrList g_threadList" (?g_threadList@@3VCPtrList@@A) already defined in ServerDlg.obj....
用extern static