libpqxx
The C++ client library for PostgreSQL
Loading...
Searching...
No Matches
header-pre.hxx
1
/* Compiler settings for compiling libpqxx headers, and workarounds for all.
2
*
3
* Include this before including any other libpqxx headers from within libpqxx.
4
* And to balance it out, also include header-post.hxx at the end of the batch
5
* of headers.
6
*
7
* The public libpqxx headers (e.g. `<pqxx/connection>`) include this already;
8
* there's no need to do this from within an application.
9
*
10
* Include this file at the highest aggregation level possible to avoid nesting
11
* and to keep things simple.
12
*
13
* Copyright (c) 2000-2025, Jeroen T. Vermeulen.
14
*
15
* See COPYING for copyright license. If you did not receive a file called
16
* COPYING with this source code, please notify the distributor of this
17
* mistake, or contact the author.
18
*/
19
20
#if __has_include(<version>)
21
# include <version>
22
#endif
23
24
// NO GUARD HERE! This part should be included every time this file is.
25
#if defined(_MSC_VER)
26
27
// Save compiler's warning state, and set warning level 4 for maximum
28
// sensitivity to warnings.
29
# pragma warning(push, 4)
30
31
// Visual C++ generates some entirely unreasonable warnings. Disable them.
32
// Copy constructor could not be generated.
33
# pragma warning(disable : 4511)
34
// Assignment operator could not be generated.
35
# pragma warning(disable : 4512)
36
// Can't expose outside classes without exporting them. Except the MSVC docs
37
// say please ignore the warning if it's a standard library class.
38
# pragma warning(disable : 4251)
39
// Can't derive library classes from outside classes without exporting them.
40
// Except the MSVC docs say please ignore the warning if the parent class is
41
// in the standard library.
42
# pragma warning(disable : 4275)
43
// Can't inherit from non-exported class.
44
# pragma warning(disable : 4275)
45
46
#endif
// _MSC_VER
47
48
49
#if defined(PQXX_HEADER_PRE)
50
# error "Avoid nesting #include of pqxx/internal/header-pre.hxx."
51
#endif
52
53
#define PQXX_HEADER_PRE
54
55
56
// Workarounds & definitions that need to be included even in library's headers
57
#include "pqxx/config-public-compiler.h"
58
59
// MSVC has a nonstandard definition of __cplusplus.
60
#if defined(_MSC_VER)
61
# define PQXX_CPLUSPLUS _MSVC_LANG
62
#else
63
# define PQXX_CPLUSPLUS __cplusplus
64
#endif
65
66
67
#if defined(PQXX_HAVE_GCC_PURE)
69
# define PQXX_PURE __attribute__((pure))
70
#else
71
# define PQXX_PURE
/* pure */
72
#endif
73
74
75
#if defined(__GNUC__)
77
# define PQXX_COLD __attribute__((cold))
78
#else
79
# define PQXX_COLD
/* cold */
80
#endif
81
82
83
// Workarounds for Windows
84
#ifdef _WIN32
85
86
/* For now, export DLL symbols if _DLL is defined. This is done automatically
87
* by the compiler when linking to the dynamic version of the runtime library,
88
* according to "gzh"
89
*/
90
# if defined(PQXX_SHARED) && !defined(PQXX_LIBEXPORT)
91
# define PQXX_LIBEXPORT __declspec(dllimport)
92
# endif
// PQXX_SHARED && !PQXX_LIBEXPORT
93
94
95
// Workarounds for Microsoft Visual C++
96
# ifdef _MSC_VER
97
98
// Suppress vtables on abstract classes.
99
# define PQXX_NOVTABLE __declspec(novtable)
100
101
// Automatically link with the appropriate libpq (static or dynamic, debug or
102
// release). The default is to use the release DLL. Define PQXX_PQ_STATIC to
103
// link to a static version of libpq, and _DEBUG to link to a debug version.
104
// The two may be combined.
105
# if defined(PQXX_AUTOLINK)
106
# if defined(PQXX_PQ_STATIC)
107
# ifdef _DEBUG
108
# pragma comment(lib, "libpqd")
109
# else
110
# pragma comment(lib, "libpq")
111
# endif
112
# else
113
# ifdef _DEBUG
114
# pragma comment(lib, "libpqddll")
115
# else
116
# pragma comment(lib, "libpqdll")
117
# endif
118
# endif
119
# endif
120
121
// If we're not compiling libpqxx itself, automatically link with the
122
// appropriate libpqxx library. To link with the libpqxx DLL, define
123
// PQXX_SHARED; the default is to link with the static library. A static link
124
// is the recommended practice.
125
//
126
// The preprocessor macro PQXX_INTERNAL is used to detect whether we
127
// are compiling the libpqxx library itself. When you compile the library
128
// yourself using your own project file, make sure to include this macro.
129
# if defined(PQXX_AUTOLINK) && !defined(PQXX_INTERNAL)
130
# ifdef PQXX_SHARED
131
# ifdef _DEBUG
132
# pragma comment(lib, "libpqxxD")
133
# else
134
# pragma comment(lib, "libpqxx")
135
# endif
136
# else
// !PQXX_SHARED
137
# ifdef _DEBUG
138
# pragma comment(lib, "libpqxx_staticD")
139
# else
140
# pragma comment(lib, "libpqxx_static")
141
# endif
142
# endif
143
# endif
144
145
# endif
// _MSC_VER
146
147
#elif defined(PQXX_HAVE_GCC_VISIBILITY)
// !_WIN32
148
149
# define PQXX_LIBEXPORT __attribute__((visibility("default")))
150
# define PQXX_PRIVATE __attribute__((visibility("hidden")))
151
152
#endif
// PQXX_HAVE_GCC_VISIBILITY
153
154
155
#ifndef PQXX_LIBEXPORT
156
# define PQXX_LIBEXPORT
/* libexport */
157
#endif
158
159
#ifndef PQXX_PRIVATE
160
# define PQXX_PRIVATE
/* private */
161
#endif
162
163
#ifndef PQXX_NOVTABLE
164
# define PQXX_NOVTABLE
/* novtable */
165
#endif
166
167
// C++20: Assume support.
168
#if defined(PQXX_HAVE_LIKELY)
169
# define PQXX_LIKELY [[likely]]
170
# define PQXX_UNLIKELY [[unlikely]]
171
#else
172
# define PQXX_LIKELY
/* [[likely]] */
173
# define PQXX_UNLIKELY
/* [[unlikely]] */
174
#endif
175
176
177
// C++23: Assume support.
178
#if defined(PQXX_HAVE_ASSUME)
179
# define PQXX_ASSUME(condition) [[assume(condition)]]
180
#else
181
# define PQXX_ASSUME(condition) while (false)
182
#endif
include
pqxx
internal
header-pre.hxx
Generated by
1.13.2