I want to import some C code but override its main()
function. I can do this in Unix by prefacing the C code\'s main declaration with __attribute__((weak)
There's another way with MSVC that I think would work if you care to use it.
/* * pWeakValue MUST be an extern const variable, which will be aliased to * pDefaultWeakValue if no real user definition is present, thanks to the * alternatename directive. */ extern const char * pWeakValue; extern const char * pDefaultWeakValue = NULL; #pragma comment(linker, "/alternatename:_pWeakValue=_pDefaultWeakValue")
See this old SO answer for some other options.
There's also __declspec(selectany)