怎么解决重复定义有关问题error LNK2005: "" (?inta@@3HA) already defined

如何解决重复定义问题error LNK2005: "***" (?inta@@3HA) already defined
在一个MFC自动生成的对话框工程里随便添加一个头文件testdefH.h,如下:

#ifndef testdefH_def
#define testdefH_def
int inta;
int ReturnA();
#endif

在其cpp文件中引用头文件,cpp文件如下:
#include"stdafx.h"
#include "testdefH.h"
int ReturnA()
{
return inta;
}

在MFC自动生成的对话框cpp文件中(testdefDlg.cpp)引用该头文件,其余代码不做任何改动:
#include "stdafx.h"
#include "testdef.h"
#include "testdefDlg.h"
#include "testdefH.h"

编译后报错:

--------------------Configuration: testdef - Win32 Debug--------------------
Linking...
testdefCPP.obj : error LNK2005: "int inta" (?inta@@3HA) already defined in testdefDlg.obj
Debug/testdef.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.

testdef.exe - 2 error(s), 0 warning(s)


对于上面的错误我觉得很纳闷,我已经在testdefH.h头文件中加入防重复定义的语句了啊,如下:
#ifndef   testdefH_def
#define testdefH_def
#endif
按理讲应该该头文件只定义一次,为什么还会出现重复定义??

------解决方案--------------------
#ifdef并不是你想象的那个作用
它用于防止一个头文件在一个源文件里被多次包含,并不能阻止一个头文件在多个源文件里被包含——当然也没理由阻止
重复定义,是“多个源文件中有同名的全局变量”
虽然我知道你是想要“多个源文件都能访问同一个全局变量”,但那必须使用extern
------解决方案--------------------
#ifndef testdefH_def
#define testdefH_def
extern int inta;
int ReturnA();
#endif

然后在一个cpp里: int inta;