libpqxx
The C++ client library for PostgreSQL
header-pre.hxx
Go to the documentation of this file.
1
// NOLINT(llvm-header-guard)
2
/* Compiler settings for compiling libpqxx headers, and workarounds for all.
3
*
4
* Include this before including any other libpqxx headers from within libpqxx.
5
* And to balance it out, also include header-post.hxx at the end of the batch
6
* of headers.
7
*
8
* The public libpqxx headers (e.g. `<pqxx/connection>`) include this already;
9
* there's no need to do this from within an application.
10
*
11
* Include this file at the highest aggregation level possible to avoid nesting
12
* and to keep things simple.
13
*
14
* Copyright (c) 2000-2026, Jeroen T. Vermeulen.
15
*
16
* See COPYING for copyright license. If you did not receive a file called
17
* COPYING with this source code, please notify the distributor of this
18
* mistake, or contact the author.
19
*/
20
21
#if __has_include(<version>)
22
# include <version>
23
#endif
24
25
// NO GUARD HERE! This part should be included every time this file is.
26
#if defined(_MSC_VER)
27
28
// Save compiler's warning state, and set warning level 4 for maximum
29
// sensitivity to warnings.
30
# pragma warning(push, 4)
31
32
// Visual C++ generates some entirely unreasonable warnings. Disable them.
33
# pragma warning(disable : 4061 4251 4275 4275 4511 4512 4514 4623 4625)
34
# pragma warning(disable : 4626 4702 4820 4868 5026 5027 5031 5045 6294)
35
36
#endif
// _MSC_VER
37
38
39
#if defined(PQXX_HEADER_PRE)
40
# error "Avoid nesting #include of pqxx/internal/header-pre.hxx."
41
#endif
42
43
#define PQXX_HEADER_PRE
44
45
46
// Configuration macros enabled by the build system.
47
#include "
pqxx/internal/config.h
"
48
49
// MSVC has a nonstandard definition of __cplusplus.
50
#if defined(_MSC_VER)
51
# define PQXX_CPLUSPLUS _MSVC_LANG
52
#else
53
# define PQXX_CPLUSPLUS __cplusplus
54
#endif
55
56
#if __has_cpp_attribute(gnu::pure)
58
62
# define PQXX_PURE [[gnu::pure]]
63
#else
64
# define PQXX_PURE
/* pure */
65
#endif
66
67
68
#if __has_cpp_attribute(gnu::hot)
70
# define PQXX_HOT [[gnu::hot]]
71
#else
72
# define PQXX_HOT
/* hot */
73
#endif
74
75
76
#if __has_cpp_attribute(gnu::cold)
78
# define PQXX_COLD [[gnu::cold]]
79
#else
80
# define PQXX_COLD
/* cold */
81
#endif
82
83
84
#if __has_cpp_attribute(gnu::always_inline)
86
# define PQXX_INLINE_ONLY [[gnu::always_inline]]
87
#elif __has_cpp_attribute(msvc::forceinline)
89
# define PQXX_INLINE_ONLY [[msvc::forceinline]]
90
#else
91
# define PQXX_INLINE_ONLY
/* always inline */
92
#endif
93
94
96
103
#if defined(PQXX_COVERAGE) && __has_cpp_attribute(gnu::always_inline)
104
# define PQXX_INLINE_COV [[gnu::always_inline]]
105
#else
106
# define PQXX_INLINE_COV
/* inline-only on coverage runs */
107
#endif
108
109
111
114
#if __has_cpp_attribute(gnu::noinline)
115
# define PQXX_NOINLINE [[gnu::noinline]]
116
#elif __has_cpp_attribute(msvc::noinline)
117
# define PQXX_NOINLINE [[msvc::noinline]]
118
#else
119
# define PQXX_NOINLINE
/* noinline */
120
#endif
121
122
123
#if __has_cpp_attribute(gnu::returns_nonnull)
125
# define PQXX_RETURNS_NONNULL [[gnu::returns_nonnull]]
126
#else
127
# define PQXX_RETURNS_NONNULL
/* returns nonnull */
128
#endif
129
130
131
#if __has_cpp_attribute(gnu::null_terminated_string_arg)
133
# define PQXX_ZARG(n) [[gnu::null_terminated_string_arg((n))]]
134
#else
135
# define PQXX_ZARG(n)
/* null-terminated string arg */
136
#endif
137
138
139
// Not all gcc versions we're seeing support the argument-less version.
140
#if defined(PQXX_HAVE_ZARGS)
142
# define PQXX_ZARGS [[gnu::null_terminated_string_arg]]
143
#else
144
# define PQXX_ZARGS
/* null-terminated string args */
145
#endif
146
147
148
// C++ extension similar to C's "restrict" keyword.
152
#if defined(PQXX_HAVE_UU_RESTRICT)
153
# define PQXX_RESTRICT __restrict
154
#else
155
# define PQXX_RESTRICT
/* restrict */
156
#endif
157
158
159
// Workarounds for Windows
160
#ifdef _WIN32
161
162
/* For now, export DLL symbols if _DLL is defined. This is done automatically
163
* by the compiler when linking to the dynamic version of the runtime library,
164
* according to "gzh"
165
*/
166
# if defined(PQXX_SHARED) && !defined(PQXX_LIBEXPORT)
167
# define PQXX_LIBEXPORT __declspec(dllimport)
168
# endif
// PQXX_SHARED && !PQXX_LIBEXPORT
169
170
171
// Workarounds for Microsoft Visual C++
172
# ifdef _MSC_VER
173
174
// Suppress vtables on abstract classes.
175
# define PQXX_NOVTABLE __declspec(novtable)
176
177
// Automatically link with the appropriate libpq (static or dynamic, debug or
178
// release). The default is to use the release DLL. Define PQXX_PQ_STATIC to
179
// link to a static version of libpq, and _DEBUG to link to a debug version.
180
// The two may be combined.
181
# if defined(PQXX_AUTOLINK)
182
# if defined(PQXX_PQ_STATIC)
183
# ifdef _DEBUG
184
# pragma comment(lib, "libpqd"
)
185
# else
186
# pragma comment(lib, "libpq"
)
187
# endif
188
# else
189
# ifdef _DEBUG
190
# pragma comment(lib, "libpqddll"
)
191
# else
192
# pragma comment(lib, "libpqdll"
)
193
# endif
194
# endif
195
# endif
196
197
// If we're not compiling libpqxx itself, automatically link with the
198
// appropriate libpqxx library. To link with the libpqxx DLL, define
199
// PQXX_SHARED; the default is to link with the static library. A static link
200
// is the recommended practice.
201
//
202
// The preprocessor macro PQXX_INTERNAL is used to detect whether we
203
// are compiling the libpqxx library itself. When you compile the library
204
// yourself using your own project file, make sure to include this macro.
205
# if defined(PQXX_AUTOLINK) && !defined(PQXX_INTERNAL)
206
# ifdef PQXX_SHARED
207
# ifdef _DEBUG
208
# pragma comment(lib, "libpqxxD"
)
209
# else
210
# pragma comment(lib, "libpqxx"
)
211
# endif
212
# else
// !PQXX_SHARED
213
# ifdef _DEBUG
214
# pragma comment(lib, "libpqxx_staticD"
)
215
# else
216
# pragma comment(lib, "libpqxx_static"
)
217
# endif
218
# endif
219
# endif
220
221
# endif
// _MSC_VER
222
223
#elif defined(PQXX_HAVE_GCC_VISIBILITY)
// !_WIN32
224
225
# define PQXX_LIBEXPORT [[gnu::visibility("default"
)]]
226
# define PQXX_PRIVATE [[gnu::visibility("hidden"
)]]
227
228
#endif
// PQXX_HAVE_GCC_VISIBILITY
229
230
231
#ifndef PQXX_LIBEXPORT
232
# define PQXX_LIBEXPORT
/* libexport */
233
#endif
234
235
#ifndef PQXX_PRIVATE
236
# define PQXX_PRIVATE
/* private */
237
#endif
238
239
#ifndef PQXX_NOVTABLE
240
# define PQXX_NOVTABLE
/* novtable */
241
#endif
242
243
// C++23: Assume support.
244
#if defined(PQXX_HAVE_ASSUME)
245
# define PQXX_ASSUME(condition) [[assume(condition)]]
246
#else
247
# define PQXX_ASSUME(condition) while (false)
248
#endif
config.h
include
pqxx
internal
header-pre.hxx
Generated by
1.9.1