Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vSKh1-00BgwD-1J for pgsql-hackers@arkaria.postgresql.org; Sun, 07 Dec 2025 19:45:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vSKh0-00DqSX-0E for pgsql-hackers@arkaria.postgresql.org; Sun, 07 Dec 2025 19:45:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vSKgz-00DqSN-2a for pgsql-hackers@lists.postgresql.org; Sun, 07 Dec 2025 19:45:14 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vSKgy-003irX-0N for pgsql-hackers@lists.postgresql.org; Sun, 07 Dec 2025 19:45:13 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 5B7Jj7h42844371; Sun, 7 Dec 2025 14:45:08 -0500 From: Tom Lane To: Jelte Fennema-Nio cc: PostgreSQL Hackers , Thomas Munro Subject: Re: Make copyObject work in C++ In-reply-to: References: Comments: In-reply-to Jelte Fennema-Nio message dated "Fri, 05 Dec 2025 15:46:57 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2844369.1765136707.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 07 Dec 2025 14:45:07 -0500 Message-ID: <2844370.1765136707@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Jelte Fennema-Nio writes: > 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++. Hmm, this only fixes the one use-case. Admittedly we have only one use-case, but as soon as we have another we'll have a new problem. How about instead modifying the macro? Maybe something like this in c.h (untested): #ifdef __cplusplus #undef typeof #define typeof decltype #define HAVE_TYPEOF 1 #endif > Another approach would be to force the value of HAVE_TYPEOF to 0 if __cp= lusplus. That would be sad, because we'd lose the type checking ability of copyObject() in C++ code. BTW, grepping finds a number of random references to __typeof__ and __typeof, which probably ought to be updated to be just typeof. regards, tom lane