From e6be287bbfa6beda038ec8b085300c5dc9c2ecd8 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sat, 4 Apr 2026 12:02:56 +0200 Subject: Use macro for [static N] --- src/utils/compilers.h | 17 ++++++++++++++--- src/utils/wrapthread.h | 4 ++-- 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src/utils') diff --git a/src/utils/compilers.h b/src/utils/compilers.h index a7d6df5..1b175bb 100644 --- a/src/utils/compilers.h +++ b/src/utils/compilers.h @@ -1,13 +1,24 @@ #if defined(__GNUC__) -#define unused __attribute__((unused)) +#define UNUSED __attribute__((unused)) +#define SIZE(x) static (x) +#define NON_NULL SIZE(1) #elif defined(__clang__) -#define unused __attribute__((unused)) +#define UNUSED __attribute__((unused)) +#define SIZE(x) static (x) +#define NON_NULL SIZE(1) #else -#define unused +/* +For example MSVC, which is not fully C11 compliant (e.g. it does not support +a[static N] notation for array parameters). +*/ + +#define UNUSED +#define SIZE(x) +#define NON_NULL #endif diff --git a/src/utils/wrapthread.h b/src/utils/wrapthread.h index 4ac72a6..9578293 100644 --- a/src/utils/wrapthread.h +++ b/src/utils/wrapthread.h @@ -61,8 +61,8 @@ #define wrapthread_return_t int #define wrapthread_return_val 0 - #define wrapthread_define_var_thread_t(x) unused char x - #define wrapthread_define_var_mutex_t(x) unused char x + #define wrapthread_define_var_thread_t(x) UNUSED char x + #define wrapthread_define_var_mutex_t(x) UNUSED char x #define wrapthread_define_struct_thread_t(x) char x #define wrapthread_define_struct_mutex_t(x) char x -- cgit v1.3