libpqxx  7.2.0
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-2020, 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(__GNUC__) && defined(PQXX_HAVE_GCC_PURE)
24 # 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 // Suppress vtables on abstract classes.
47 # define PQXX_NOVTABLE __declspec(novtable)
48 
49 // Automatically link with the appropriate libpq (static or dynamic, debug or
50 // release). The default is to use the release DLL. Define PQXX_PQ_STATIC to
51 // link to a static version of libpq, and _DEBUG to link to a debug version.
52 // The two may be combined.
53 # if defined(PQXX_AUTOLINK)
54 # if defined(PQXX_PQ_STATIC)
55 # ifdef _DEBUG
56 # pragma comment(lib, "libpqd")
57 # else
58 # pragma comment(lib, "libpq")
59 # endif
60 # else
61 # ifdef _DEBUG
62 # pragma comment(lib, "libpqddll")
63 # else
64 # pragma comment(lib, "libpqdll")
65 # endif
66 # endif
67 # endif
68 
69 // If we're not compiling libpqxx itself, automatically link with the
70 // appropriate libpqxx library. To link with the libpqxx DLL, define
71 // PQXX_SHARED; the default is to link with the static library. A static link
72 // is the recommended practice.
73 //
74 // The preprocessor macro PQXX_INTERNAL is used to detect whether we
75 // are compiling the libpqxx library itself. When you compile the library
76 // yourself using your own project file, make sure to include this macro.
77 # if defined(PQXX_AUTOLINK) && !defined(PQXX_INTERNAL)
78 # ifdef PQXX_SHARED
79 # ifdef _DEBUG
80 # pragma comment(lib, "libpqxxD")
81 # else
82 # pragma comment(lib, "libpqxx")
83 # endif
84 # else // !PQXX_SHARED
85 # ifdef _DEBUG
86 # pragma comment(lib, "libpqxx_staticD")
87 # else
88 # pragma comment(lib, "libpqxx_static")
89 # endif
90 # endif
91 # endif
92 
93 # endif // _MSC_VER
94 #endif // _WIN32
95 
96 
97 #ifndef PQXX_LIBEXPORT
98 # define PQXX_LIBEXPORT
99 #endif
100 
101 #ifndef PQXX_PRIVATE
102 # define PQXX_PRIVATE
103 #endif
104 
105 #ifndef PQXX_NOVTABLE
106 # define PQXX_NOVTABLE
107 #endif
108 
109 #endif