C++ 在gtest中使用fff.h模拟系统API

C++ 在gtest中使用fff.h模拟系统API,c++,c,mocking,googletest,C++,C,Mocking,Googletest,我在gtest中使用fff.h模拟calloc函数时遇到了一个问题。有谁能告诉我如何解决这个问题吗 我的代码如下 #include <iostream> #include "gtest/gtest.h" #include "stub_sys.h" #include "sav_v2x_secif.h" #include "fff.h" extern "C" { DEFINE_FFF_GLOBALS; //FAKE_VALUE_FUNC(void *, calloc,

我在gtest中使用fff.h模拟calloc函数时遇到了一个问题。有谁能告诉我如何解决这个问题吗 我的代码如下

#include <iostream>
#include "gtest/gtest.h"
#include "stub_sys.h"
#include "sav_v2x_secif.h"
#include "fff.h"

extern "C" {
    DEFINE_FFF_GLOBALS;
    //FAKE_VALUE_FUNC(void *, calloc, size_t, size_t);
    FAKE_VALUE_FUNC(void *, malloc, size_t);

}

它告诉您异常说明符是不同的:
void*malloc(size\u t)
vs
void*malloc(size\u t)throw()
;看起来像是C++与C混合的问题,我不确定到底是什么。我的PC上也不能复制。用G++ 7.4编译它,代码< NM- D/COD>显示符号<代码> MalCopyFase。这是由于C++和C中的冲突定义引起的。我尝试在GTestFraseC中测试基于C的代码。它告诉你异常说明符是不同的:<代码> VAT*MALLC(SIEZHETT)< /> VS >代码> Vult*Malc(sisiHyt)抛出()< /C> >;看起来像是C++与C混合的问题,我不确定到底是什么。我的PC上也不能复制。用G++ 7.4编译它,代码< NM- D/COD>显示符号<代码> MalCopyFase。这是由于C++和C中的冲突定义引起的。我正在尝试在GTestFrestor中测试基于C的代码。
X86/staging_dir/include/fff.h:1679:68: error: declaration of ‘void* malloc(size_t)’ has a different exception specifier
     RETURN_TYPE FFF_GCC_FUNCTION_ATTRIBUTES FUNCNAME(ARG0_TYPE arg0){ \
                                                                    ^
X86/staging_dir/include/fff.h:6524:19: note: in definition of macro ‘EXPAND’
 #define EXPAND(x) x
                   ^
X86/staging_dir/include/fff.h:6548:32: note: in expansion of macro ‘EXPAND’
 #define FUNC_VALUE_(N,...)     EXPAND(FUNC_VALUE_N(N,__VA_ARGS__))
                                ^
X86/staging_dir/include/fff.h:6550:33: note: in expansion of macro ‘EXPAND’
 #define FUNC_VALUE_N(N,...)     EXPAND(FAKE_VALUE_FUNC ## N(__VA_ARGS__))
                                 ^
X86/staging_dir/include/fff.h:1714:5: note: in expansion of macro ‘DEFINE_FAKE_VALUE_FUNC1’
     DEFINE_FAKE_VALUE_FUNC1(RETURN_TYPE, FUNCNAME, ARG0_TYPE) \
     ^
X86/staging_dir/include/fff.h:6550:40: note: in expansion of macro ‘FAKE_VALUE_FUNC1’
 #define FUNC_VALUE_N(N,...)     EXPAND(FAKE_VALUE_FUNC ## N(__VA_ARGS__))
                                        ^
X86/staging_dir/include/fff.h:6548:39: note: in expansion of macro ‘FUNC_VALUE_N’
 #define FUNC_VALUE_(N,...)     EXPAND(FUNC_VALUE_N(N,__VA_ARGS__))
                                       ^
X86/staging_dir/include/fff.h:6546:41: note: in expansion of macro ‘FUNC_VALUE_’
 #define FAKE_VALUE_FUNC(...)     EXPAND(FUNC_VALUE_(PP_NARG_MINUS2(__VA_ARGS__), __VA_ARGS__))
                                         ^
X86/tmp/tmp/test/test_tmp.cpp:10:5: note: in expansion of macro ‘FAKE_VALUE_FUNC’
     FAKE_VALUE_FUNC(void *, malloc, size_t);
     ^
X86/tmp/tmp/test/test_tmp.cpp:10:29: error: from previous declaration ‘void* malloc(size_t) throw ()’
     FAKE_VALUE_FUNC(void *, malloc, size_t);