Skip to content
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

When is it necessary to guard FFF macros with extern C? #88

Open
thekenu opened this issue Apr 17, 2020 · 1 comment
Open

When is it necessary to guard FFF macros with extern C? #88

thekenu opened this issue Apr 17, 2020 · 1 comment

Comments

@thekenu
Copy link

thekenu commented Apr 17, 2020

I am using fff to mock inputs to these embedded C functions and using gtest (C++ framework) to run test suites. Naturally, the embedded C code must be imported into gtest files using extern C. Is it ALSO necessary to guard things like DECLARE_FAKE_VOID_FUNC with extern C in this case? The project seems to compile either way so I'm curious if there's a best practice.

@leonardopsantos
Copy link

the embedded C code must be imported into gtest files using extern C

You mean you have to add extern "C" guards around C header files?

extern "C"
{
#include <some_c_header.h>
}

Is it ALSO necessary to guard things like DECLARE_FAKE_VOID_FUNC with extern C in this case

I don't know which linker you're using, but with the GNU linker, unless I wrap the fakes like so:

extern "C"
{
FAKE_VALUE_FUNC(uint8_t , some_function, uint8_t);
}

I get a linker error because of name mangling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants