Re: Make copyObject work in C++

Jelte Fennema-Nio <postgres@jeltef.nl>

From: "Jelte Fennema-Nio" <postgres@jeltef.nl>
To: "Tom Lane" <tgl@sss.pgh.pa.us>
Cc: "PostgreSQL Hackers" <pgsql-hackers@lists.postgresql.org>, "Thomas Munro" <thomas.munro@gmail.com>
Date: 2025-12-08T08:11:59Z
Lists: pgsql-hackers

Attachments

On Sun Dec 7, 2025 at 8:45 PM CET, Tom Lane wrote:
> #ifdef __cplusplus
> #undef typeof
> #define typeof decltype
> #define HAVE_TYPEOF 1
> #endif

Went with defining pg_exprtype (pg_typeof already exists). Undefining
typeof seemed a bit heavy-handed. Especially since I think it would be
nice to backport this so C++ extensions can use copyObject directly.

> BTW, grepping finds a number of random references to __typeof__ and
> __typeof, which probably ought to be updated to be just typeof.

Added a follow on patch that starts using pg_exrtype in all those
places.