Make copyObject work in C++

From: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Subject: Make copyObject work in C++
Date: 2025-12-05 14:46:57
Message-ID: CAGECzQR21OnnKiZO_1rLWO0-16kg1JBxnVq-wymYW0-_1cUNtg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Calling copyObject fails in C++ with an error like in most setups:

error: use of undeclared identifier 'typeof'; did you mean 'typeid'

This is due to the C compiler supporting used to compile postgres
supporting typeof, but that function actually not being present in the
C++ compiler. This fixes that by using decltype instead of typeof when
including the header in C++.

Realized because of Thomas' not about how much of our headers should
work in C++, and remembering I hit this specific problem myself.

Another approach would be to force the value of HAVE_TYPEOF to 0 if __cplusplus.

Attachment Content-Type Size
v1-0001-Make-copyObject-work-in-C.patch application/x-patch 1.3 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-12-05 14:47:17 Re: Consistently use palloc_object() and palloc_array()
Previous Message Jelte Fennema-Nio 2025-12-05 14:32:32 Re: Safer hash table initialization macro