I have a header file in a Windows compile using the Intel compiler. The header looks something like this:
#ifdef _MAIN
Loggerp logger;
#else
extern Loggerp logger;
#endif
The _MAIN macro is defined in a C++ file and there is a C file that includes the header. This generates a "...LNK2019: unresolved external symbol..." because the C++ compile decorates (mangles) the 'logger' name such that the linker can't match the undecorated C name with the decorated C++ name.
The MSVC docs state that the MS compiler will support both 'extern "C"' and 'extern "C++"'. However, the Intel compiler marks the quote mark of 'extern "' as an error.
Anyone know how to get the Intel compiler to mark this reference so that it can be linked to both C++ and C ?
// when compiling C++ code, use the non-mangled C names
#ifdef __cplusplus
# define EXTERN extern "C"
#else
# define EXTERN extern
#endif
EXTERN Loggerp logger;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With