在某个头文件中定义一个命名空间,该命名空间中定义一个变量,该头文件也被#ifndef保护,如果这个头文件被多次包含,则会在编译中出现ldreturned 1 exit status的错误。请问有大神知道是怎么回事吗?
代码:
test.h
#ifndef TEST_H
namespace test{
int a;
}
#endif
test1.cpp
#include"test.h"
main.cpp
#include"test.h"
int main(){
return 0;
}
IDE是codeblocks, 在32位和64位的mingw gcc 中均测试过有问题。报错是 ld returned 1 exit status.
谢谢
代码:
test.h
#ifndef TEST_H
namespace test{
int a;
}
#endif
test1.cpp
#include"test.h"
main.cpp
#include"test.h"
int main(){
return 0;
}
IDE是codeblocks, 在32位和64位的mingw gcc 中均测试过有问题。报错是 ld returned 1 exit status.
谢谢