mirror of
https://github.com/postgres/postgres.git
synced 2026-04-15 22:10:45 -04:00
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
This commit is contained in:
parent
735e8fe685
commit
f8e7ca3285
1 changed files with 36 additions and 4 deletions
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Reference in a new issue