Reputation: 11431
I have a header "myHeaderFile.h" file looks as below which is used by both release exe and unit test exe.
#ifndef MYHEADERFILE_H
#define MYHEADERFILE_H
namespace myname1
{
namespace myname2
{
class A
{
...
};
#ifdef MYTESTCLASS
class TestABase
{
...
}
#endif
}
}
#endif
Now we have for unittest file myUnitTest.h file file as below
#ifndef MYUNITEST_H
#define MYUNITTEST_H
#ifndef MYTESTCLASS
#define MYTESTCLASS 1
#endif
#include "myHeaderFile.h"
class TestClass : public myname1::myname2::TestABase
{
...
};
#endif
now in myUnitTest.cpp i have following
#include "myUnitTest.h"
// Definition stuff.
When i compile i am getting error as error C2039: TestABase: is not a member of myname1::myname2' myUnitTest.h(31): error C2504: TestABase: base class undefined
what is causing above error? Please help me in resolving above error. Note: myHeaderFile.h comes from library so i cannot change this header file.
Thanks!
Upvotes: 1
Views: 230
Reputation: 13451
You need to include myHeaderFile.h
in myUnitTest.h
. Do that after the block:
#ifndef MYTESTCLASS
#define MYTESTCLASS 1
#endif
Edit
As this did not help then there may be a problem with the MYTESTCLASS
definition. Do you include myHeaderFile.h
anywhere else? Maybe you can try to define the MYTESTCLASS
in compiler options instead of in the myUnitTest.h
header file. Maybe you can just remove the #ifdef MYTESTCLASS
check to see if that is the problem.
Upvotes: 4