Fake Function Framework "one or more multiply defined symbold found"

816 views Asked by At

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?

1

There are 1 answers

6
Armali On BEST ANSWER

The line

FAKE_VALUE_FUNC(bool, ioFunc);

in your .cpp unit test file defines the (fake) function ioFunc. The object file ioDigitalInput.obj also contains a (maybe not fake) definition of ioFunc, and you try to link this object with the compiled test, so ioFunc is multiply defined. Either don't try to link ioDigitalInput.obj, or mark the fake with the weak attribute as described in the fff README.