Environment is Microsoft Visual C++ 2015 and Windows 7.
Is there anything special about inline extern "C" functions defined in a header? I am consuming an SDK in which one of the headers contain such a beast. In my application I have a lone TU (translation unit) whose only job in life is to include the aforementioned header. That's all. Nothing else is in it. If I dig into the generated object file, I see the extern "C" function being pulled in. This is causing me some unwanted side effects (I will leave out what they are for now, as it might just distract from the main issue).
Why would this happen? There is nothing from the client code (remember my lone TU is empty except for main() entry point and that header) that is triggering this to happen.
UPDATE with a small snippet that might explain better what I am running into:
This is what is actually happening:
FooObj.h
FooObj::FooObj() { }
FooObj::~FooObj() { CallIntoAnotherC_API(); }
SDKHeader.h
#include <FooObj.h>
extern "C" inline void SomeFunc(void* user_data)
{
A* obj = static_cast<A*>(user_data);
obj->CallAnotherFunc(FooObj(33));
}
MyFile.cpp
#include "SDKHeader.h"
int main() { return 0; }
Compiling MyFile.cpp into an executable fails with the linker complaining that CallIntoAnotherC_API is an unresolved external.
inline extern "C"functions defined in a header? In a word, no. Why would this happen? What exactly? Unspecified unwanted side effects?inlinewithoutstaticorexternever useful in C99. It covers the issue from the viewpoint of the C system. See also extern inline, which may be more apposite still. Basically, in C, one source file can containextern inline …function definition…and this file will contain a non-inline function for the inline-able function.inlinein a header to be shared between C and C++, because it has different semantics in each of C++, ISO C, and GNU C. (no idea what MSVC's C compiler does with it)