ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
c_cpp_compatibility.h
Go to the documentation of this file.
1
/**
2
* @file c_cpp_compatibility.h
3
* @brief Fix gettext macro conflicts between PostgreSQL and the C++ STL.
4
*
5
* When PostgreSQL is built without @c --enable-nls, its headers redefine
6
* @c gettext, @c ngettext, @c dgettext, and @c dngettext as no-op macros.
7
* Several STL and Boost headers later include @c <libintl.h>, which tries
8
* to declare the real function prototypes for those same names. The
9
* resulting macro/declaration clash causes compilation errors.
10
*
11
* This header must be included in every translation unit that mixes
12
* PostgreSQL C headers with C++ STL or Boost headers. It undefines the
13
* four offending macros after the PostgreSQL headers have been processed,
14
* allowing @c libintl.h to declare the functions correctly.
15
*
16
* The cleanest long-term fix is to build PostgreSQL with @c --enable-nls,
17
* but that is not always under the extension author's control.
18
*/
19
#ifndef C_CPP_COMPATIBILITY_H
20
#define C_CPP_COMPATIBILITY_H
21
22
/* When compiling PostgreSQL without --enable-nls, gettext, ngettext,
23
* dgetttext, dngettext are replaced with macros; but some STL headers (in
24
* particular used by Boost) use the definitions of these functions from
25
* libintl.h; to avoid conflicts between these declarations, for files
26
* that include both C PostgreSQL headers and STL headers, we need to
27
* undefine the macros. It is usually better to compile PostgreSQL with
28
* --enable-nls, though, but we do not have control over this. */
29
30
#undef gettext
31
#undef ngettext
32
#undef dgettext
33
#undef dngettext
34
35
#endif
/* C_CPP_COMPATIBILITY_H */
← Back to provsql.org