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 // Some compilers, Visual Studio in particular, don't seem to support the
16 // standard's ISO-646 keywords out of the box.
17 #include <ciso646>
18 
19 
20 #if defined(__GNUC__) && defined(PQXX_HAVE_GCC_CONST)
21 #define PQXX_CONST __attribute__ ((const))
23 #else
24 #define PQXX_CONST
25 #endif
26 
27 #if defined(PQXX_HAVE_DEPRECATED)
28 #define PQXX_DEPRECATED [[deprecated]]
30 #elif defined(__GNUC__) && defined(PQXX_HAVE_GCC_DEPRECATED)
31 #define PQXX_DEPRECATED __attribute__ ((deprecated))
32 #else
33 #define PQXX_DEPRECATED
34 #endif
35 
36 #if defined(__GNUC__) && defined(PQXX_HAVE_GCC_PURE)
37 #define PQXX_PURE __attribute__ ((pure))
39 #else
40 #define PQXX_PURE
41 #endif
42 
43 
44 // Workarounds for Windows
45 #ifdef _WIN32
46 
47 /* For now, export DLL symbols if _DLL is defined. This is done automatically
48  * by the compiler when linking to the dynamic version of the runtime library,
49  * according to "gzh"
50  */
51 #if !defined(PQXX_LIBEXPORT) && defined(PQXX_SHARED)
52 #define PQXX_LIBEXPORT __declspec(dllimport)
53 #endif // !PQXX_LIBEXPORT && PQXX_SHARED
54 
55 
56 // Workarounds for Microsoft Visual C++
57 #ifdef _MSC_VER
58 
59 // Suppress vtables on abstract classes.
60 #define PQXX_NOVTABLE __declspec(novtable)
61 
62 // Automatically link with the appropriate libpq (static or dynamic, debug or
63 // release). The default is to use the release DLL. Define PQXX_PQ_STATIC to
64 // link to a static version of libpq, and _DEBUG to link to a debug version.
65 // The two may be combined.
66 #if defined(PQXX_AUTOLINK)
67 #if defined(PQXX_PQ_STATIC)
68 #ifdef _DEBUG
69 #pragma comment(lib, "libpqd")
70 #else
71 #pragma comment(lib, "libpq")
72 #endif
73 #else
74 #ifdef _DEBUG
75 #pragma comment(lib, "libpqddll")
76 #else
77 #pragma comment(lib, "libpqdll")
78 #endif
79 #endif
80 #endif
81 
82 // If we're not compiling libpqxx itself, automatically link with the
83 // appropriate libpqxx library. To link with the libpqxx DLL, define
84 // PQXX_SHARED; the default is to link with the static library. A static link
85 // is the recommended practice.
86 //
87 // The preprocessor macro PQXX_INTERNAL is used to detect whether we
88 // are compiling the libpqxx library itself. When you compile the library
89 // yourself using your own project file, make sure to include this macro.
90 #if defined(PQXX_AUTOLINK) && !defined(PQXX_INTERNAL)
91  #ifdef PQXX_SHARED
92  #ifdef _DEBUG
93  #pragma comment(lib, "libpqxxD")
94  #else
95  #pragma comment(lib, "libpqxx")
96  #endif
97  #else // !PQXX_SHARED
98  #ifdef _DEBUG
99  #pragma comment(lib, "libpqxx_staticD")
100  #else
101  #pragma comment(lib, "libpqxx_static")
102  #endif
103  #endif
104 #endif
105 
106 #endif // _MSC_VER
107 #endif // _WIN32
108 
109 
110 #ifndef PQXX_LIBEXPORT
111 #define PQXX_LIBEXPORT
112 #endif
113 
114 #ifndef PQXX_PRIVATE
115 #define PQXX_PRIVATE
116 #endif
117 
118 #ifndef PQXX_NOVTABLE
119 #define PQXX_NOVTABLE
120 #endif
121 
122 #endif