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.