v2-0001-Fixes-for-C-typeof-implementation.patch
text/plain
Filename: v2-0001-Fixes-for-C-typeof-implementation.patch
Type: text/plain
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v2-0001
Subject: Fixes for C++ typeof implementation
| File | + | − |
|---|---|---|
| src/include/c.h | 9 | 0 |
From f2f750f7c3ab6b73514ab2fd5f02185abe9ad59f Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Fri, 6 Mar 2026 13:31:01 +0100
Subject: [PATCH v2 1/3] Fixes for C++ typeof implementation
This fixes two bugs in commit 1887d822f14.
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.
---
src/include/c.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/include/c.h b/src/include/c.h
index f66c752d4a0..5b678283469 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -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)
--
2.53.0