libpqxx  7.5.2
compiler-public.hxx
1 /* Definitions and settings for compiling libpqxx, and client software.
2  *
3  * Include this before any other libpqxx code. To do that, put it at the top
4  * of every public libpqxx header file.
5  *
6  * Copyright (c) 2000-2021, Jeroen T. Vermeulen.
7  *
8  * See COPYING for copyright license. If you did not receive a file called
9  * COPYING with this source code, please notify the distributor of this
10  * mistake, or contact the author.
11  */
12 #ifndef PQXX_H_COMPILER_PUBLIC
13 #define PQXX_H_COMPILER_PUBLIC
14 
15 // Workarounds & definitions that need to be included even in library's headers
16 #include "pqxx/config-public-compiler.h"
17 
18 // Enable ISO-646 keywords: "and" instead of "&&" etc. Some compilers have
19 // them by default, others may need this header.
20 #include <ciso646>
21 
22 
23 #if defined(PQXX_HAVE_GCC_PURE)
25 # define PQXX_PURE __attribute__((pure))
26 #else
27 # define PQXX_PURE
28 #endif
29 
30 
31 // Workarounds for Windows
32 #ifdef _WIN32
33 
34 /* For now, export DLL symbols if _DLL is defined. This is done automatically
35  * by the compiler when linking to the dynamic version of the runtime library,
36  * according to "gzh"
37  */
38 # if defined(PQXX_SHARED) && !defined(PQXX_LIBEXPORT)
39 # define PQXX_LIBEXPORT __declspec(dllimport)
40 # endif // PQXX_SHARED && !PQXX_LIBEXPORT
41 
42 
43 // Workarounds for Microsoft Visual C++
44 # ifdef _MSC_VER
45 
46 // Workarounds for deprecated attribute syntax error in Visual Studio 2017.
47 # if _MSC_VER < 1920
48 # define PQXX_DEPRECATED(MESSAGE) __declspec(deprecated(# MESSAGE))
49 # endif
50 
51 // Suppress vtables on abstract classes.
52 # define PQXX_NOVTABLE __declspec(novtable)
53 
54 // Automatically link with the appropriate libpq (static or dynamic, debug or
55 // release). The default is to use the release DLL. Define PQXX_PQ_STATIC to
56 // link to a static version of libpq, and _DEBUG to link to a debug version.
57 // The two may be combined.
58 # if defined(PQXX_AUTOLINK)
59 # if defined(PQXX_PQ_STATIC)
60 # ifdef _DEBUG
61 # pragma comment(lib, "libpqd")
62 # else
63 # pragma comment(lib, "libpq")
64 # endif
65 # else
66 # ifdef _DEBUG
67 # pragma comment(lib, "libpqddll")
68 # else
69 # pragma comment(lib, "libpqdll")
70 # endif
71 # endif
72 # endif
73 
74 // If we're not compiling libpqxx itself, automatically link with the
75 // appropriate libpqxx library. To link with the libpqxx DLL, define
76 // PQXX_SHARED; the default is to link with the static library. A static link
77 // is the recommended practice.
78 //
79 // The preprocessor macro PQXX_INTERNAL is used to detect whether we
80 // are compiling the libpqxx library itself. When you compile the library
81 // yourself using your own project file, make sure to include this macro.
82 # if defined(PQXX_AUTOLINK) && !defined(PQXX_INTERNAL)
83 # ifdef PQXX_SHARED
84 # ifdef _DEBUG
85 # pragma comment(lib, "libpqxxD")
86 # else
87 # pragma comment(lib, "libpqxx")
88 # endif
89 # else // !PQXX_SHARED
90 # ifdef _DEBUG
91 # pragma comment(lib, "libpqxx_staticD")
92 # else
93 # pragma comment(lib, "libpqxx_static")
94 # endif
95 # endif
96 # endif
97 
98 # endif // _MSC_VER
99 
100 #elif defined(PQXX_HAVE_GCC_VISIBILITY) // !_WIN32
101 
102 # define PQXX_LIBEXPORT __attribute__((visibility("default")))
103 # define PQXX_PRIVATE __attribute__((visibility("hidden")))
104 
105 #endif // PQXX_HAVE_GCC_VISIBILITY
106 
107 
108 #ifndef PQXX_LIBEXPORT
109 # define PQXX_LIBEXPORT
110 #endif
111 
112 #ifndef PQXX_PRIVATE
113 # define PQXX_PRIVATE
114 #endif
115 
116 #ifndef PQXX_NOVTABLE
117 # define PQXX_NOVTABLE
118 #endif
119 
120 #ifndef PQXX_DEPRECATED
121 # define PQXX_DEPRECATED(MESSAGE) [[deprecated(# MESSAGE)]]
122 #endif
123 
124 #endif