I have a source and header file like this:
FileA.h
...
//#define X_TESTMODE // --> If I set X_TESTMODE here, GTest can call the function foo()
#ifndef X_TESTMODE
#define X_STATIC static
#else
#define X_STATIC
#endif
...
FileA.c
...
X_STATIC uint8 foo(...)
{
...
}
...
In GTest, I want to set X_TESTMODE to make the static function visible for testing purposes.
ut_FileA.cc
...
extern "C" {
#define X_TESTMODE // --> This doesn't work and foo() is not visible in GTest
#include FileA.h
extern uint8 foo(...);
}
#define X_TESTMODE // --> This doesn't work and foo() is not visible in GTest
...
TEST(Test, foo){
...
uint8 x = foo(...);
...
}
If I set X_TESTMODE in FileA.h, GTest can see the foo() function, but if I set it in the GTest file ut_FileA.cc, then the foo() function is not visible.
X_TESTMODE must be set in ut_FileA.cc.
Does anyone have an idea?
New contributor
Sedat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.