Ultimately I want to end up with a single set of source files that compiles to a Windows or Linux dynamic library depending on which platform compiled it.
The problem seems to be that Windows requires that annotations be made to both the header file declarations and the source file definitions. DLL Tutorial For Beginners
Linux dynamic link libraries seem to require annotations only in the source file definitions.
I can #define a preprocessor string to handle the difference of the source code definitions.
#if (_MSC_VER >= 1900) // (Visual Studio 2015 version 14.0) #define EXPORTED __declspec(dllexport)#else #define EXPORTED __attribute__((visibility("default")))#endif
I don't know the cleanest way to get Linux to ignore the Windows header file annotations besides declaring all of the functions twice. We can define
#define EMPTY_DEFINE
In Windows and the compiler simply ignores it. In gcc it causes the compiler chokes on an unrecognized symbol.