Make copyObject work in C++ - Mailing list pgsql-hackers

From Jelte Fennema-Nio
Subject Make copyObject work in C++
Date
Msg-id CAGECzQR21OnnKiZO_1rLWO0-16kg1JBxnVq-wymYW0-_1cUNtg@mail.gmail.com
Whole thread Raw
List 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

pgsql-hackers by date:

Previous
From: Jelte Fennema-Nio
Date:
Subject: Re: Safer hash table initialization macro
Next
From: Tom Lane
Date:
Subject: Re: Consistently use palloc_object() and palloc_array()