Skip to content
Snippets Groups Projects
Commit 2b3a1740 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

static_assert() only available with C11 and higher.

parent a8c0ac5d
No related branches found
No related tags found
1 merge request!455Update branch with changes from master
Pipeline #6248 failed
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment