-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mocking System functions in gtest #84
Comments
@singh-arulraj linker-based wrapping this is what I use
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, I am required to mock calloc function in gtest framework(c++ test code).
Please let me know if I am doing anything wrong.
My Code
`
#include "fff.h"
extern "C" {
DEFINE_FFF_GLOBALS;
//FAKE_VALUE_FUNC(void *, calloc, size_t, size_t);
FAKE_VALUE_FUNC(void *, malloc, size_t);
}
`
I get the following errors
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);
The text was updated successfully, but these errors were encountered: