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

Use static_assert() macro instead of _Static_assert keyword

More compatible with C++ that way.
parent ffd5385d
Branches
Tags
1 merge request!455Update branch with changes from master
Pipeline #6246 failed
...@@ -432,7 +432,7 @@ typedef struct { ...@@ -432,7 +432,7 @@ typedef struct {
/* This is a bound-safe version of strcpy basically - only works with fixed-length arrays */ /* This is a bound-safe version of strcpy basically - only works with fixed-length arrays */
#ifdef _DEBUG #ifdef _DEBUG
#define SAFECOPY(dst,src) do { \ #define SAFECOPY(dst,src) do { \
_Static_assert(sizeof(dst) != sizeof(void*), "SAFECOPY() on pointer-sized dst, use strlcpy"); \ static_assert(sizeof(dst) != sizeof(void*), "SAFECOPY() on pointer-sized dst, use strlcpy"); \
strlcpy(dst,src,sizeof(dst)); \ strlcpy(dst,src,sizeof(dst)); \
} while(0) } while(0)
#else #else
...@@ -442,7 +442,7 @@ typedef struct { ...@@ -442,7 +442,7 @@ typedef struct {
/* Extra-safe SAFECOPY doesn't pass NULL-pointer to strncpy */ /* Extra-safe SAFECOPY doesn't pass NULL-pointer to strncpy */
#ifdef _DEBUG #ifdef _DEBUG
#define XSAFECOPY(dst,src) do { \ #define XSAFECOPY(dst,src) do { \
_Static_assert(sizeof(dst) != sizeof(void*), "SAFECOPY() on pointer-sized dst, use strlcpy"); \ static_assert(sizeof(dst) != sizeof(void*), "SAFECOPY() on pointer-sized dst, use strlcpy"); \
strlcpy(dst,(src)==NULL?"(null)":(src),sizeof(dst)); \ strlcpy(dst,(src)==NULL?"(null)":(src),sizeof(dst)); \
} while(0) } while(0)
#else #else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment