| From: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Support using copyObject in standard C++ |
| Date: | 2026-03-02 10:55:25 |
| Message-ID: | E1vx0vt-001yXB-1o@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
Support using copyObject in standard C++
Calling copyObject in C++ without GNU extensions (e.g. when using
-std=c++11 instead of -std=gnu++11) fails with an error like this:
error: use of undeclared identifier 'typeof'; did you mean 'typeid'
This is due to the C compiler used to compile PostgreSQL supporting
typeof, but that function actually not being present in the C++
compiler. This fixes that by explicitely checking for typeof support
in C++, and then either use that or define typeof ourselves as:
std::remove_reference_t<decltype(x)>
According to the paper that led to adding typeof to the C standard,
that's the C++ equivalent of the C typeof:
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2927.htm#existing-decltype
Author: Author: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
Discussion: https://www.postgresql.org/message-id/flat/DGPW5WCFY7WY.1IHCDNIVVT300%2540jeltef.nl
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/1887d822f1428637c935b9f5e8be4a2a56fb77c7
Modified Files
--------------
config/c-compiler.m4 | 29 ++++++++++++
configure | 54 ++++++++++++++++++++++
configure.ac | 1 +
meson.build | 25 ++++++++++
src/include/c.h | 21 +++++++++
src/include/pg_config.h.in | 7 +++
.../test_cplusplusext/test_cplusplusext.cpp | 2 +
7 files changed, 139 insertions(+)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Melanie Plageman | 2026-03-02 16:07:37 | pgsql: Save prune cycles by consistently clearing prune hints on all-vi |
| Previous Message | Peter Eisentraut | 2026-03-02 07:05:20 | pgsql: Check for memset_explicit() and explicit_memset() |