From: Peter Eisentraut Date: Thu, 26 Mar 2026 07:40:18 +0000 (+0100) Subject: Make fixed-length list building macros work in C++ X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f8e7ca32851082a85d628b7821ae674be09bf1f3;p=thirdparty%2Fpostgresql.git Make fixed-length list building macros work in C++ Compound literals, as used in pg_list.h for list_makeN(), are not a C++ feature. MSVC doesn't accept these. (GCC and Clang accept them, but they would warn in -pedantic mode.) Replace with equivalent inline functions. (These are the only instances of compound literals used in PostgreSQL header files.) Author: Jelte Fennema-Nio Discussion: https://www.postgresql.org/message-id/flat/CAGECzQR21OnnKiZO_1rLWO0-16kg1JBxnVq-wymYW0-_1cUNtg%40mail.gmail.com --- diff --git a/src/include/nodes/pg_list.h b/src/include/nodes/pg_list.h index ae80975548f..e93bcbf2698 100644 --- a/src/include/nodes/pg_list.h +++ b/src/include/nodes/pg_list.h @@ -204,10 +204,42 @@ list_length(const List *l) /* * Convenience macros for building fixed-length lists */ -#define list_make_ptr_cell(v) ((ListCell) {.ptr_value = (v)}) -#define list_make_int_cell(v) ((ListCell) {.int_value = (v)}) -#define list_make_oid_cell(v) ((ListCell) {.oid_value = (v)}) -#define list_make_xid_cell(v) ((ListCell) {.xid_value = (v)}) + +static inline ListCell +list_make_ptr_cell(void *v) +{ + ListCell c; + + c.ptr_value = v; + return c; +} + +static inline ListCell +list_make_int_cell(int v) +{ + ListCell c; + + c.int_value = v; + return c; +} + +static inline ListCell +list_make_oid_cell(Oid v) +{ + ListCell c; + + c.oid_value = v; + return c; +} + +static inline ListCell +list_make_xid_cell(TransactionId v) +{ + ListCell c; + + c.xid_value = v; + return c; +} #define list_make1(x1) \ list_make1_impl(T_List, list_make_ptr_cell(x1))