I have a project in visual c++ 2010, which contains preprocessor directives in a key header file. Actually, it is the ZMQ source code.
The project is normally configured to be a dll, so the header uses DLL_EXPORT’s status (defined/not defined). If the project is used to compile a dll, the header can be used by both the dll project or the client code, thanks to the following setup taken from zmq.h:
#if defined _WIN32
# if defined DLL_EXPORT
# define ZMQ_EXPORT __declspec(dllexport)
# else
# define ZMQ_EXPORT __declspec(dllimport)
# endif
However, this does not support the setup where I’m building a static library. Therefore I have to modify to header by hand.
Visual studio seems to recognize dll project setup and handle definitions for dll_export accordingly. Is there a symbol that is recognized by visual studio, that corresponds to static library setup? Basically, I’d like to handle static library compilation and usage by extending the method used in the above snippet.
I would just introduce a second (optional) macro, something like
ZMQ_STATIC:Define said macro both when building your library as a static library or when consuming it as a static library.