I am using the Fake Function Framework to fake a function in a .c file and test it in my .cpp unit test file.
#include "..\fff.h"
extern "C"
{
#include "ioDigitalInput.h"
}
DEFINE_FFF_GLOBALS;
FAKE_VALUE_FUNC(bool, ioFunc);
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTestfff
{
TEST_CLASS(UnitTestfff)
{
public:
TEST_METHOD(TestMethod1)
{
}
};
}
The function ioFunc returns a bool and takes void as input.
When I try to build the code I get the following errors: "one or more multiply defined symbols found" and "ioFunc already defined in ioDigitalInput.obj"
What am I doing wrong?
The line
in your .cpp unit test file defines the (fake) function
ioFunc. The object file ioDigitalInput.obj also contains a (maybe not fake) definition ofioFunc, and you try to link this object with the compiled test, soioFuncis multiply defined. Either don't try to link ioDigitalInput.obj, or mark the fake with the weak attribute as described in the fff README.