Re: pgsql: tests: Add a test C++ extension module - Mailing list pgsql-committers
| From | Peter Smith |
|---|---|
| Subject | Re: pgsql: tests: Add a test C++ extension module |
| Date | |
| Msg-id | CAHut+Psr0yk7nbtX63Mc5+C_dND1LV-SxO7uw=mWbvHxhKwUrQ@mail.gmail.com Whole thread Raw |
| In response to | pgsql: tests: Add a test C++ extension module (Peter Eisentraut <peter@eisentraut.org>) |
| Responses |
Re: pgsql: tests: Add a test C++ extension module
|
| List | pgsql-committers |
On Wed, Jan 21, 2026 at 2:43 AM Peter Eisentraut <peter@eisentraut.org> wrote: > > tests: Add a test C++ extension module > > While we already test that our headers are valid C++ using > headerscheck, it turns out that the macros we define might still > expand to invalid C++ code. This adds a minimal test extension that > is compiled using C++ to test that it's actually possible to build and > run extensions written in C++. Future commits will improve C++ > compatibility of some of our macros and add usage of them to this > extension make sure that they don't regress in the future. > > The test module is for the moment disabled when using MSVC. In > particular, the use of designated initializers in PG_MODULE_MAGIC > would require C++20, for which we are currently not set up. (GCC and > Clang support it as extensions.) It is planned to fix this. > > Author: Jelte Fennema-Nio <postgres@jeltef.nl> > Discussion: https://www.postgresql.org/message-id/flat/CAGECzQR21OnnKiZO_1rLWO0-16kg1JBxnVq-wymYW0-_1cUNtg@mail.gmail.com > > Branch > ------ > master > > Details > ------- > https://git.postgresql.org/pg/commitdiff/476b35d4e311a3d77a550280d93393e518908b27 > > Modified Files > -------------- > configure | 8 +++++ > configure.ac | 7 ++++ > src/Makefile.global.in | 2 ++ > src/makefiles/meson.build | 2 ++ > src/test/modules/Makefile | 6 ++++ > src/test/modules/meson.build | 1 + > src/test/modules/test_cplusplusext/.gitignore | 3 ++ > src/test/modules/test_cplusplusext/Makefile | 26 ++++++++++++++ > src/test/modules/test_cplusplusext/README | 10 ++++++ > .../expected/test_cplusplusext.out | 7 ++++ > src/test/modules/test_cplusplusext/meson.build | 42 ++++++++++++++++++++++ > .../test_cplusplusext/sql/test_cplusplusext.sql | 3 ++ > .../test_cplusplusext/test_cplusplusext--1.0.sql | 8 +++++ > .../test_cplusplusext/test_cplusplusext.control | 4 +++ > .../test_cplusplusext/test_cplusplusext.cpp | 37 +++++++++++++++++++ > 15 files changed, 166 insertions(+) > Hi. 'make check-world' is suddenly failing for me, apparently caused by this new test. FYI - I am building in a 'Linux CentOS7-x64 ' environment, which I know has reached end-of-life, but even so, everything was fine before this test appeared. ====== Kind Regards, Peter Smith. Fujitsu Australia ~~~ install.log output is below: make[4]: Entering directory `/home/postgres/oss_postgres_misc/src/test/modules/test_cplusplusext' for extra in src/test/modules/test_cplusplusext; do make -C '../../../..'/$extra DESTDIR='/home/postgres/oss_postgres_misc'/tmp_install install || exit; done make[5]: Entering directory `/home/postgres/oss_postgres_misc/src/test/modules/test_cplusplusext' g++ -Wall -Wpointer-arith -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -O2 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -I. -I. -I../../../../src/include -D_GNU_SOURCE -c -o test_cplusplusext.o test_cplusplusext.cpp In file included from test_cplusplusext.cpp:19:0: ../../../../src/include/fmgr.h:510:1: warning: identifier ‘static_assert’ is a keyword in C++11 [-Wc++0x-compat] StaticAssertDecl(sizeof(FMGR_ABI_EXTRA) <= sizeof(((Pg_abi_values *) 0)->abi_extra), ^ In file included from ../../../../src/include/c.h:57:0, from ../../../../src/include/postgres.h:48, from test_cplusplusext.cpp:18: ../../../../src/include/pg_config.h:552:25: error: expected identifier before numeric constant #define MAXIMUM_ALIGNOF 8 ^ ../../../../src/include/c.h:1113:10: note: in expansion of macro ‘MAXIMUM_ALIGNOF’ alignas(MAXIMUM_ALIGNOF) char data[BLCKSZ]; ^ ../../../../src/include/pg_config.h:552:25: error: expected ‘,’ or ‘...’ before numeric constant #define MAXIMUM_ALIGNOF 8 ^ ../../../../src/include/c.h:1113:10: note: in expansion of macro ‘MAXIMUM_ALIGNOF’ alignas(MAXIMUM_ALIGNOF) char data[BLCKSZ]; ^ In file included from ../../../../src/include/postgres.h:48:0, from test_cplusplusext.cpp:18: ../../../../src/include/c.h:1113:25: error: ISO C++ forbids declaration of ‘alignas’ with no type [-fpermissive] alignas(MAXIMUM_ALIGNOF) char data[BLCKSZ]; ^ ../../../../src/include/c.h:1113:25: error: expected ‘;’ at end of member declaration In file included from ../../../../src/include/c.h:58:0, from ../../../../src/include/postgres.h:48, from test_cplusplusext.cpp:18: ../../../../src/include/pg_config_manual.h:223:27: error: expected identifier before numeric constant #define PG_IO_ALIGN_SIZE 4096 ^ ../../../../src/include/c.h:1113:25: error: expected ‘;’ at end of member declaration In file included from ../../../../src/include/c.h:58:0, from ../../../../src/include/postgres.h:48, from test_cplusplusext.cpp:18: ../../../../src/include/pg_config_manual.h:223:27: error: expected identifier before numeric constant #define PG_IO_ALIGN_SIZE 4096 ^ ../../../../src/include/c.h:1126:10: note: in expansion of macro ‘PG_IO_ALIGN_SIZE’ alignas(PG_IO_ALIGN_SIZE) char data[BLCKSZ]; ^ In file included from ../../../../src/include/postgres.h:48:0, from test_cplusplusext.cpp:18: ../../../../src/include/c.h:1126:26: error: ISO C++ forbids declaration of ‘alignas’ with no type [-fpermissive] alignas(PG_IO_ALIGN_SIZE) char data[BLCKSZ]; ^ ../../../../src/include/c.h:1126:26: error: expected ‘;’ at end of member declaration In file included from ../../../../src/include/c.h:58:0, from ../../../../src/include/postgres.h:48, from test_cplusplusext.cpp:18: ../../../../src/include/pg_config_manual.h:223:27: error: expected identifier before numeric constant #define PG_IO_ALIGN_SIZE 4096 ^ ../../../../src/include/c.h:1132:10: note: in expansion of macro ‘PG_IO_ALIGN_SIZE’ alignas(PG_IO_ALIGN_SIZE) char data[XLOG_BLCKSZ]; ^ ../../../../src/include/pg_config_manual.h:223:27: error: expected ‘,’ or ‘...’ before numeric constant #define PG_IO_ALIGN_SIZE 4096 ^ ../../../../src/include/c.h:1132:10: note: in expansion of macro ‘PG_IO_ALIGN_SIZE’ alignas(PG_IO_ALIGN_SIZE) char data[XLOG_BLCKSZ]; ^ In file included from ../../../../src/include/postgres.h:48:0, from test_cplusplusext.cpp:18: ../../../../src/include/c.h:1132:26: error: ISO C++ forbids declaration of ‘alignas’ with no type [-fpermissive] alignas(PG_IO_ALIGN_SIZE) char data[XLOG_BLCKSZ]; ^ ../../../../src/include/c.h:1132:26: error: expected ‘;’ at end of member declaration ../../../../src/include/c.h:943:15: error: expected constructor, destructor, or type conversion before ‘(’ token static_assert(condition, errmessage) ^ ../../../../src/include/fmgr.h:510:1: note: in expansion of macro ‘StaticAssertDecl’ StaticAssertDecl(sizeof(FMGR_ABI_EXTRA) <= sizeof(((Pg_abi_values *) 0)->abi_extra), ^ make[5]: *** [test_cplusplusext.o] Error 1 make[5]: Leaving directory `/home/postgres/oss_postgres_misc/src/test/modules/test_cplusplusext' make[4]: *** [checkprep] Error 2 make[4]: Leaving directory `/home/postgres/oss_postgres_misc/src/test/modules/test_cplusplusext' make[3]: *** [checkprep-test_cplusplusext-recurse] Error 2
pgsql-committers by date: