From 2b3a174068b33c4c947b2b2124b4c8486ad5b01a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net> Date: Fri, 22 Mar 2024 14:47:49 -0400 Subject: [PATCH] static_assert() only available with C11 and higher. --- src/xpdev/gen_defs.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/xpdev/gen_defs.h b/src/xpdev/gen_defs.h index cb19438229..cdd8c06d90 100644 --- a/src/xpdev/gen_defs.h +++ b/src/xpdev/gen_defs.h @@ -432,7 +432,9 @@ typedef struct { /* This is a bound-safe version of strcpy basically - only works with fixed-length arrays */ #ifdef _DEBUG #define SAFECOPY(dst,src) do { \ +#if __STDC_VERSION__ >= 201112L static_assert(sizeof(dst) != sizeof(void*), "SAFECOPY() on pointer-sized dst, use strlcpy"); \ +#endif strlcpy(dst,src,sizeof(dst)); \ } while(0) #else @@ -442,7 +444,9 @@ typedef struct { /* Extra-safe SAFECOPY doesn't pass NULL-pointer to strlcpy */ #ifdef _DEBUG #define XSAFECOPY(dst,src) do { \ +#if __STDC_VERSION__ >= 201112L static_assert(sizeof(dst) != sizeof(void*), "SAFECOPY() on pointer-sized dst, use strlcpy"); \ +#endif strlcpy(dst,(src)==NULL?"(null)":(src),sizeof(dst)); \ } while(0) #else -- GitLab