mirror of
https://github.com/postgres/postgres.git
synced 2026-03-22 18:33:19 -04:00
Fixes for C++ typeof implementation
This fixes two bugs in commit 1887d822f1.
First, if we are using the fallback C++ implementation of typeof, then
we need to include the C++ header <type_traits> for
std::remove_reference_t. This header is also likely to be used for
other C++ implementations of type tricks, so we'll put it into the
global includes.
Second, for the case that the C compiler supports typeof in a spelling
that is not "typeof" (for example, __typeof__), then we need to #undef
typeof in the C++ section to avoid warnings about duplicate macro
definitions.
Reviewed-by: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://www.postgresql.org/message-id/flat/92f9750f-c7f6-42d8-9a4a-85a3cbe808f3%40eisentraut.org
This commit is contained in:
parent
d4a080b8a1
commit
9c05f152b5
1 changed files with 9 additions and 0 deletions
|
|
@ -82,6 +82,14 @@
|
|||
#endif
|
||||
#ifdef ENABLE_NLS
|
||||
#include <libintl.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C++"
|
||||
{
|
||||
/* This header is used in the definition of various C++ things below. */
|
||||
#include <type_traits>
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Pull in fundamental symbols that we also expose to applications */
|
||||
|
|
@ -435,6 +443,7 @@
|
|||
* [1]: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2927.htm#existing-decltype
|
||||
*/
|
||||
#if defined(__cplusplus)
|
||||
#undef typeof
|
||||
#ifdef pg_cxx_typeof
|
||||
#define typeof(x) pg_cxx_typeof(x)
|
||||
#elif !defined(HAVE_CXX_TYPEOF)
|
||||
|
|
|
|||
Loading…
Reference in a new issue