From 58c33270c280aafe85a1eacb224efdd9138fdb19 Mon Sep 17 00:00:00 2001 From: Cloudwalk Date: Tue, 20 Jul 2021 14:14:54 -0400 Subject: [PATCH] common: Define DP_STATIC_ASSERT which wraps static_assert --- common.h | 7 +++++++ sys_sdl.c | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/common.h b/common.h index 5338d514..d71899fe 100644 --- a/common.h +++ b/common.h @@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define COMMON_H #include +#include #include "qtypes.h" #include "qdefs.h" @@ -216,6 +217,12 @@ void COM_InitGameType (void); char *va(char *buf, size_t buflen, const char *format, ...) DP_FUNC_PRINTF(3); // does a varargs printf into provided buffer, returns buffer (so it can be called in-line unlike dpsnprintf) +// GCC with -Werror=c++-compat will error out if static_assert is used even though the macro is valid C11... +#ifndef __cplusplus +#define DP_STATIC_ASSERT(expr, str) _Static_assert(expr, str) +#else +#define DP_STATIC_ASSERT(expr, str) static_assert(expr, str) +#endif // snprintf and vsnprintf are NOT portable. Use their DP counterparts instead #ifdef snprintf diff --git a/sys_sdl.c b/sys_sdl.c index 50cca9d9..15a626d3 100644 --- a/sys_sdl.c +++ b/sys_sdl.c @@ -1,5 +1,3 @@ -#include "darkplaces.h" - #ifdef WIN32 #include #include "conio.h" @@ -15,8 +13,14 @@ #include +/* + * Include this BEFORE darkplaces.h because it breaks wrapping + * _Static_assert. Cloudwalk has no idea how or why so don't ask. + */ #include +#include "darkplaces.h" + #ifdef WIN32 #ifdef _MSC_VER #pragma comment(lib, "sdl2.lib") -- 2.39.2