Derive-C
Loading...
Searching...
No Matches
zerosized.h
Go to the documentation of this file.
1#pragma once
2
4// on release).
5// - In gcc/clang C a struct with a zero sized array is itself zero sized.
6// - In C++ this is not valid, and the type must be at least 1 byte. Hence for compatibility, zero
7// sized is size 1 in C++
8#ifdef __cplusplus
9 #define ZERO_SIZED(TYPE) \
10 typedef struct { \
11 char zero_sized_marker[1]; \
12 } TYPE; \
13 static_assert(sizeof(TYPE) == 1)
14#else
15 #define ZERO_SIZED(TYPE) \
16 typedef struct { \
17 char zero_sized_marker[0]; \
18 } TYPE; \
19 _Static_assert(sizeof(TYPE) == 0)
20#endif