我有一个MFC应用程序AVT_testapp,并在头文件(AVT_testappDlg.h)我想,以使其全球创建的所有功能,类等变量外。 每当我尝试这样做,但(我说试试int x = 7
),我得到的错误:
1>AVT_testappDlg.obj : error LNK2005: "int x" (?x@@3HA) already defined in
AVT_testapp.obj
1>..\..\bin\x64\Debug\AVT_testapp.exe : fatal error LNK1169: one or more
multiply defined symbols found
我已经在谷歌找到的一切说“只需要添加页眉卫士”。 AVT_testappDlg拥有6#包括的,他们每个人都有标题警卫。
还有什么可以创建全局变量时引起这些错误?
编辑:这是我的头文件的开头,
#pragma once
#include "../../src/CoreUtils/nierr.h"
#include "..\..\src\CoreUtils\StringHelpers.h" //includes windows.h
#include "afxwin.h"
#include "afxcmn.h"
#include "IFrameObserver.h"
#include "c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include\GdiPlusHeaders.h"
//#include <fstream>
//#include <windows.h>
int x = 7;
using namespace AVT::VmbAPI;
//////////////////////////////////////////////////////////////////////////
////////// MyObserver class ///////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
class MyObserver : public IFrameObserver
{
private:
MyObserver( MyObserver& );
MyObserver& operator=( const MyObserver& );
public:
VmbUchar_t* imageData;
//...
//...
//...
//...
//that's the end of the relevant stuff