libpqxx
compiler-public.hxx
1 
9 #ifndef PQXX_H_COMPILER_PUBLIC
10 #define PQXX_H_COMPILER_PUBLIC
11 
12 // Workarounds & definitions that need to be included even in library's headers
13 #include "pqxx/config-public-compiler.h"
14 
15 // Workarounds for SUN Workshop 6
16 #if defined(__SUNPRO_CC)
17 #define PQXX_PRIVATE __hidden
18 #endif // __SUNPRO_CC
19 
20 
21 #if defined(__GNUC__) && defined(PQXX_HAVE_GCC_CONST)
22 #define PQXX_CONST __attribute__ ((const))
24 #else
25 #define PQXX_CONST
26 #endif
27 
28 #if defined(PQXX_HAVE_DEPRECATED)
29 #define PQXX_DEPRECATED [[deprecated]]
31 #elif defined(__GNUC__) && defined(PQXX_HAVE_GCC_DEPRECATED)
32 #define PQXX_DEPRECATED __attribute__ ((deprecated))
33 #else
34 #define PQXX_DEPRECATED
35 #endif
36 
37 #if defined(__GNUC__) && defined(PQXX_HAVE_GCC_PURE)
38 #define PQXX_PURE __attribute__ ((pure))
40 #else
41 #define PQXX_PURE
42 #endif
43 
44 
45 // Workarounds for Windows
46 #ifdef _WIN32
47 
48 /* For now, export DLL symbols if _DLL is defined. This is done automatically
49  * by the compiler when linking to the dynamic version of the runtime library,
50  * according to "gzh"
51  */
52 // TODO: Define custom macro to govern how libpqxx will be linked to client
53 #if !defined(PQXX_LIBEXPORT) && defined(PQXX_SHARED)
54 #define PQXX_LIBEXPORT __declspec(dllimport)
55 #endif // !PQXX_LIBEXPORT && PQXX_SHARED
56 
57 
58 // Workarounds for Microsoft Visual C++
59 #ifdef _MSC_VER
60 
61 // Suppress vtables on abstract classes.
62 #define PQXX_NOVTABLE __declspec(novtable)
63 
64 // Automatically link with the appropriate libpq (static or dynamic, debug or
65 // release). The default is to use the release DLL. Define PQXX_PQ_STATIC to
66 // link to a static version of libpq, and _DEBUG to link to a debug version.
67 // The two may be combined.
68 #if defined(PQXX_AUTOLINK)
69 #if defined(PQXX_PQ_STATIC)
70 #ifdef _DEBUG
71 #pragma comment(lib, "libpqd")
72 #else
73 #pragma comment(lib, "libpq")
74 #endif
75 #else
76 #ifdef _DEBUG
77 #pragma comment(lib, "libpqddll")
78 #else
79 #pragma comment(lib, "libpqdll")
80 #endif
81 #endif
82 #endif
83 
84 // If we're not compiling libpqxx itself, automatically link with the
85 // appropriate libpqxx library. To link with the libpqxx DLL, define
86 // PQXX_SHARED; the default is to link with the static library. A static link
87 // is the recommended practice.
88 //
89 // The preprocessor macro PQXX_INTERNAL is used to detect whether we
90 // are compiling the libpqxx library itself. When you compile the library
91 // yourself using your own project file, make sure to include this macro.
92 #if defined(PQXX_AUTOLINK) && !defined(PQXX_INTERNAL)
93  #ifdef PQXX_SHARED
94  #ifdef _DEBUG
95  #pragma comment(lib, "libpqxxD")
96  #else
97  #pragma comment(lib, "libpqxx")
98  #endif
99  #else // !PQXX_SHARED
100  #ifdef _DEBUG
101  #pragma comment(lib, "libpqxx_staticD")
102  #else
103  #pragma comment(lib, "libpqxx_static")
104  #endif
105  #endif
106 #endif
107 
108 #endif // _MSC_VER
109 #endif // _WIN32
110 
111 
112 #ifndef PQXX_LIBEXPORT
113 #define PQXX_LIBEXPORT
114 #endif
115 
116 #ifndef PQXX_PRIVATE
117 #define PQXX_PRIVATE
118 #endif
119 
120 #ifndef PQXX_NOVTABLE
121 #define PQXX_NOVTABLE
122 #endif
123 
124 #endif