mdbx: fix zero-length arrays for C++.

Change-Id: I24ee4b34064f1face40d63861fb2f8982b922f7d
This commit is contained in:
Leonid Yuriev 2020-07-30 14:52:27 +03:00
parent f4021c8028
commit 7ce33be933

View File

@ -242,7 +242,7 @@ typedef union mdbx_safe64 {
#if MDBX_64BIT_ATOMIC #if MDBX_64BIT_ATOMIC
volatile uint64_t atomic; volatile uint64_t atomic;
#endif /* MDBX_64BIT_ATOMIC */ #endif /* MDBX_64BIT_ATOMIC */
struct { __anonymous_struct_extension__ struct {
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
volatile uint32_t low; volatile uint32_t low;
volatile uint32_t high; volatile uint32_t high;
@ -364,7 +364,7 @@ typedef struct MDBX_page {
#define P_KEEP 0x8000 /* leave this page alone during spill */ #define P_KEEP 0x8000 /* leave this page alone during spill */
uint16_t mp_flags; uint16_t mp_flags;
union { union {
struct { __anonymous_struct_extension__ struct {
indx_t mp_lower; /* lower bound of free space */ indx_t mp_lower; /* lower bound of free space */
indx_t mp_upper; /* upper bound of free space */ indx_t mp_upper; /* upper bound of free space */
}; };
@ -372,8 +372,10 @@ typedef struct MDBX_page {
}; };
pgno_t mp_pgno; /* page number */ pgno_t mp_pgno; /* page number */
/* dynamic size */ #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
indx_t mp_ptrs[/* C99 */]; (!defined(__cplusplus) && defined(_MSC_VER))
indx_t mp_ptrs[] /* dynamic size */;
#endif /* C99 */
} MDBX_page; } MDBX_page;
/* Size of the page header, excluding dynamic data at the end */ /* Size of the page header, excluding dynamic data at the end */
@ -551,8 +553,11 @@ typedef struct MDBX_lockinfo {
volatile unsigned mti_numreaders; volatile unsigned mti_numreaders;
volatile unsigned mti_readers_refresh_flag; volatile unsigned mti_readers_refresh_flag;
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
(!defined(__cplusplus) && defined(_MSC_VER))
alignas(MDBX_CACHELINE_SIZE) /* cacheline ---------------------------------*/ alignas(MDBX_CACHELINE_SIZE) /* cacheline ---------------------------------*/
MDBX_reader mti_readers[/* C99 */]; MDBX_reader mti_readers[] /* dynamic size */;
#endif /* C99 */
} MDBX_lockinfo; } MDBX_lockinfo;
/* Lockfile format signature: version, features and field layout */ /* Lockfile format signature: version, features and field layout */
@ -629,11 +634,11 @@ typedef txnid_t *MDBX_TXL;
/* An Dirty-Page list item is an pgno/pointer pair. */ /* An Dirty-Page list item is an pgno/pointer pair. */
typedef union MDBX_DP { typedef union MDBX_DP {
struct { __anonymous_struct_extension__ struct {
pgno_t pgno; pgno_t pgno;
MDBX_page *ptr; MDBX_page *ptr;
}; };
struct { __anonymous_struct_extension__ struct {
unsigned sorted; unsigned sorted;
unsigned length; unsigned length;
}; };
@ -1297,7 +1302,11 @@ typedef struct MDBX_node {
/* valid flags for mdbx_node_add() */ /* valid flags for mdbx_node_add() */
#define NODE_ADD_FLAGS (F_DUPDATA | F_SUBDATA | MDBX_RESERVE | MDBX_APPEND) #define NODE_ADD_FLAGS (F_DUPDATA | F_SUBDATA | MDBX_RESERVE | MDBX_APPEND)
uint8_t mn_data[/* C99 */]; /* key and data are appended here */
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
(!defined(__cplusplus) && defined(_MSC_VER))
uint8_t mn_data[] /* key and data are appended here */;
#endif /* C99 */
} MDBX_node; } MDBX_node;
#define DB_PERSISTENT_FLAGS \ #define DB_PERSISTENT_FLAGS \