Re: Make copyObject work in C++
Peter Eisentraut <peter@eisentraut.org>
From: Peter Eisentraut <peter@eisentraut.org>
To: Andres Freund <andres@anarazel.de>
Cc: Jelte Fennema-Nio <postgres@jeltef.nl>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
Thomas Munro <thomas.munro@gmail.com>
Date: 2026-01-20T19:07:15Z
Lists: pgsql-hackers
On 20.01.26 17:38, Andres Freund wrote: >> I have split your first patch further. For a start, I left out the >> PG_MODULE_MAGIC*-related changes and disabled the module under MSVC. This >> has been committed. I plan to let the buildfarm run with it for a day or >> two and then add in the basic MSVC support. > Seems like billbug doesn't like this: > > https://buildfarm.postgresql.org/cgi-bin/show_log.pl? > nm=billbug&dt=2026-01-20%2016%3A00%3A02 > > gmake[1]: Entering directory '/home/marcel/build-farm-20/buildroot/HEAD/pgsql.build/src/test/modules/test_cplusplusext' > g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wshadow=compatible-local -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -O2 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -I. -I. -I../../../../src/include -D_POSIX_C_SOURCE=200112L -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS -I/usr/openssl/3/include -I/usr/include/libxml2 -c -o test_cplusplusext.o test_cplusplusext.cpp > In file included from ../../../../src/include/postgres.h:48, > from test_cplusplusext.cpp:18: > ../../../../src/include/c.h:158:21: error: '_Noreturn' does not name a type; did you mean 'pg_noreturn'? > 158 | #define pg_noreturn _Noreturn > | ^~~~~~~~~ > ../../../../src/include/c.h:918:1: note: in expansion of macro 'pg_noreturn' > 918 | pg_noreturn extern void ExceptionalCondition(const char *conditionName, > | ^~~~~~~~~~~ It's getting confused by _Noreturn, which is defined thus: #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L #define pg_noreturn _Noreturn But apparently on these Solaris-related platforms, g++ defines __STDC_VERSION__ even in C++ mode. (Confirmed in local testing.) Apparently, this is even allowed by the C++ standard. So the smallest fix is probably to gate this more like this: #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) && !defined(__cplusplus) #define pg_noreturn _Noreturn (Eventually, we could add support for C++ attributes, but one step at a time.)
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Enable test_cplusplusext with MSVC
- c05ad248f99c 19 (unreleased) landed
-
Disable some C++ warnings in MSVC
- 82a7cbea747c 19 (unreleased) landed
-
meson: Make room for C++-only warning flags for MSVC
- 4c83f1253593 19 (unreleased) landed
-
Make fixed-length list building macros work in C++
- f8e7ca328510 19 (unreleased) landed
-
Make unconstify and unvolatize use StaticAssertVariableIsOfTypeMacro
- 258248d0bdbf 19 (unreleased) landed
-
Use typeof everywhere instead of compiler specific spellings
- e2308350c9b7 19 (unreleased) landed
-
Test List macros in C++ extensions
- 3d28ecb5ac76 19 (unreleased) landed
-
Test most StaticAssert macros in C++ extensions
- 451650eaacd5 19 (unreleased) landed
-
Revert "Change copyObject() to use typeof_unqual"
- 0af05b5dbb42 19 (unreleased) landed
-
Fix for C++ compatibility
- b4555cb070f1 19 (unreleased) landed
-
tests: Add a test C++ extension module
- 476b35d4e311 19 (unreleased) landed