Skip to content

Commit

Permalink
types: fix clang-tidy warning (gcc bit fields workaround)
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed Nov 6, 2024
1 parent 36c3306 commit 895e583
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions include/re_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,30 @@ typedef int re_sock_t;

#define HAVE_RE_ARG 1

#if defined(__clang__)
#define RE_ARG_SIZE(type) \
_Generic((type), \
bool: sizeof(int), \
char: sizeof(int), \
unsigned char: sizeof(unsigned int), \
short: sizeof(int), \
unsigned short: sizeof(unsigned int), \
int: sizeof(int), \
unsigned int: sizeof(unsigned int), \
long: sizeof(long), \
unsigned long: sizeof(unsigned long), \
long long: sizeof(long long), \
unsigned long long: sizeof(unsigned long long), \
float: sizeof(double), \
double: sizeof(double), \
char const*: sizeof(char const *), \
char*: sizeof(char *), \
void const*: sizeof(void const *), \
void*: sizeof(void *), \
struct pl: sizeof(struct pl), \
default: sizeof(void*) \
)
#else /* GCC bit fields workaround */
#define RE_ARG_SIZE(type) \
_Generic((0)?(type):(type), \
bool: sizeof(int), \
Expand All @@ -321,6 +345,7 @@ typedef int re_sock_t;
struct pl: sizeof(struct pl), \
default: sizeof(void*) \
)
#endif

#define RE_ARG_0() 0
#define RE_ARG_1(expr) RE_ARG_SIZE(expr), (expr), 0
Expand Down

0 comments on commit 895e583

Please sign in to comment.