I am trying to mock functions from an external library with FFF (Fake Function Framework). The functions are kinda weird declared and I have no idea how to do it.
lib.h
...
// XWF_GetItemInformation
typedef INT64 (__stdcall *fptr_XWF_GetItemInformation) (LONG nItemID,
LONG nInfoType, LPBOOL lpSuccess);
...
extern fptr_XWF_GetItemInformation XWF_GetItemInformation;
...
lib.cpp
...
fptr_XWF_GetItemInformation XWF_GetItemInformation;
...
LONG __stdcall XT_RetrieveFunctionPointers()
{
...
XWF_GetItemInformation = (fptr_XWF_GetItemInformation) GetProcAddress(Hdl, "XWF_GetItemInformation");
...
}
I am mocking it with:
#include <fff/fff.h>
#include <lib.h>
FAKE_VALUE_FUNC(INT64, XWF_GetItemInformation, LONG, LONG, LPBOOL);
But this gives the error (shortened):
In file included from external/xwf/item.test.cpp:5:
external/fff/fff.h:1793:100: error: 'INT64 XWF_GetItemInformation(LONG, LONG, LPBOOL)' redeclared as different kind of entity
1793 | RETURN_TYPE FFF_GCC_FUNCTION_ATTRIBUTES FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2); \
| ^
...
external/xwf/x-tension.fff.h:9:1: note: in expansion of macro 'FAKE_VALUE_FUNC'
9 | FAKE_VALUE_FUNC(INT64, XWF_GetItemInformation, LONG, LONG, LPBOOL)
| ^~~~~~~~~~~~~~~
In file included from external/xwf/x-tension.h:14,
from external/xwf/x-tension.fff.h:5,
from external/xwf/item.test.cpp:7:
external/xwf/x-tension/X-Tension.h:322:36: note: previous declaration 'INT64 (* XWF_GetItemInformation)(LONG, LONG, LPBOOL)'
322 | extern fptr_XWF_GetItemInformation XWF_GetItemInformation;
| ^~~~~~~~~~~~~~~~~~~~~~
In file included from external/xwf/item.test.cpp:5:
external/fff/fff.h:1797:100: error: 'INT64 XWF_GetItemInformation(LONG, LONG, LPBOOL)' redeclared as different kind of entity
1797 | RETURN_TYPE FFF_GCC_FUNCTION_ATTRIBUTES FUNCNAME(ARG0_TYPE arg0, ARG1_TYPE arg1, ARG2_TYPE arg2){ \
|
...
In file included from external/xwf/x-tension.h:14,
from external/xwf/x-tension.fff.h:5,
from external/xwf/item.test.cpp:7:
external/xwf/x-tension/X-Tension.h:322:36: note: previous declaration 'INT64 (* XWF_GetItemInformation)(LONG, LONG, LPBOOL)'
322 | extern fptr_XWF_GetItemInformation XWF_GetItemInformation;
| ^~~~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:201: build/xwf/item.test.o] Error 1
Can someone help me how I can mock this function?