tests: Add a test C++ extension module
authorPeter Eisentraut <peter@eisentraut.org>
Tue, 20 Jan 2026 15:24:57 +0000 (16:24 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Tue, 20 Jan 2026 15:42:30 +0000 (16:42 +0100)
commit476b35d4e311a3d77a550280d93393e518908b27
treeb5bf3e6fb508ab7591395a7ff8f0a2b0f38f3887
parentf1cd34f95272fe62aa9378f9164431399e94a135
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
15 files changed:
configure
configure.ac
src/Makefile.global.in
src/makefiles/meson.build
src/test/modules/Makefile
src/test/modules/meson.build
src/test/modules/test_cplusplusext/.gitignore [new file with mode: 0644]
src/test/modules/test_cplusplusext/Makefile [new file with mode: 0644]
src/test/modules/test_cplusplusext/README [new file with mode: 0644]
src/test/modules/test_cplusplusext/expected/test_cplusplusext.out [new file with mode: 0644]
src/test/modules/test_cplusplusext/meson.build [new file with mode: 0644]
src/test/modules/test_cplusplusext/sql/test_cplusplusext.sql [new file with mode: 0644]
src/test/modules/test_cplusplusext/test_cplusplusext--1.0.sql [new file with mode: 0644]
src/test/modules/test_cplusplusext/test_cplusplusext.control [new file with mode: 0644]
src/test/modules/test_cplusplusext/test_cplusplusext.cpp [new file with mode: 0644]