我在stdafx.h中有下面的代碼。任何人都知道如何修復編譯錯誤:LNK2005? (源代碼裏面)
using namespace std;
typedef struct {
DWORD address;
DWORD size;
char file[64];
DWORD line;
} ALLOC_INFO;
typedef list<ALLOC_INFO*> AllocList;
//AllocList *allocList;
沒有評論的代碼(最後一行),它編譯得很好。但是當我添加評論的代碼時,我得到以下錯誤。
error LNK2005: "class std::list > * allocList" ([email protected]@[email protected][email protected]@[email protected][email protected]@@[email protected]@@[email protected]@A) already defined in test.obj
我正在使用Visual Studio .NET 2003.任何人都有任何想法是什麼以及如何解決它?
這應該是我的回答(所以我得到通知)的評論,但無論如何我都會回答。如果只有一個包含stdafx.h的C++源文件,那麼該代碼就可以工作。否則,它會得到鏈接錯誤 - 我懷疑它從來沒有在多文件實際安裝中測試過。 – paxdiablo 2009-01-12 05:40:35