postgres.git / summary / log / commit / refs

commit    f8e7ca32851082a85d628b7821ae674be09bf1f3
Author:   Peter Eisentraut <peter@eisentraut.org>
Date:     Thu Mar 26 07:40:18 2026 +0000

    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 <postgres@jeltef.nl>
    Discussion: https://www.postgresql.org/message-id/flat/CAGECzQR21OnnKiZO_1rLWO0-16kg1JBxnVq-wymYW0-_1cUNtg%40mail.gmail.com


src/include/nodes/pg_list.h | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) 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)) [parent: 735e8fe68535]