OpenMM
 All Classes Namespaces Functions Variables Enumerations Enumerator Friends
windowsExport.h
1 #ifndef OPENMM_WINDOWSEXPORT_H_
2 #define OPENMM_WINDOWSEXPORT_H_
3 
4 /*
5  * Shared libraries are messy in Visual Studio. We have to distinguish three
6  * cases:
7  * (1) this header is being used to build the OpenMM shared library
8  * (dllexport)
9  * (2) this header is being used by a *client* of the OpenMM shared
10  * library (dllimport)
11  * (3) we are building the OpenMM static library, or the client is
12  * being compiled with the expectation of linking with the
13  * OpenMM static library (nothing special needed)
14  * In the CMake script for building this library, we define one of the symbols
15  * OpenMM_BUILDING_{SHARED|STATIC}_LIBRARY
16  * Client code normally has no special symbol defined, in which case we'll
17  * assume it wants to use the shared library. However, if the client defines
18  * the symbol OPENMM_USE_STATIC_LIBRARIES we'll suppress the dllimport so
19  * that the client code can be linked with static libraries. Note that
20  * the client symbol is not library dependent, while the library symbols
21  * affect only the OpenMM library, meaning that other libraries can
22  * be clients of this one. However, we are assuming all-static or all-shared.
23  */
24 
25 #ifdef _MSC_VER
26  // We don't want to hear about how sprintf is "unsafe".
27  #pragma warning(disable:4996)
28  // Keep MS VC++ quiet about lack of dll export of private members.
29  #pragma warning(disable:4251)
30  #if defined(OPENMM_BUILDING_SHARED_LIBRARY)
31  #define OPENMM_EXPORT __declspec(dllexport)
32  #elif defined(OPENMM_BUILDING_STATIC_LIBRARY) || defined(OPENMM_USE_STATIC_LIBRARIES)
33  #define OPENMM_EXPORT
34  #else
35  #define OPENMM_EXPORT __declspec(dllimport) // i.e., a client of a shared library
36  #endif
37 #else
38  #define OPENMM_EXPORT // Linux, Mac
39 #endif
40 
41 #endif // OPENMM_WINDOWSEXPORT_H_