]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Support using copyObject in standard C++
authorPeter Eisentraut <peter@eisentraut.org>
Mon, 2 Mar 2026 10:46:02 +0000 (11:46 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Mon, 2 Mar 2026 10:48:13 +0000 (11:48 +0100)
commit1887d822f1428637c935b9f5e8be4a2a56fb77c7
treede0f43a05610f1b9372257b5a19da91eea1bf873
parent386ca3908de28dd882a62b8f97a329db07b23138
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@jeltef.nl>
Discussion: https://www.postgresql.org/message-id/flat/DGPW5WCFY7WY.1IHCDNIVVT300%2540jeltef.nl
config/c-compiler.m4
configure
configure.ac
meson.build
src/include/c.h
src/include/pg_config.h.in
src/test/modules/test_cplusplusext/test_cplusplusext.cpp