Browse Source

Add static assert to catch errors in COPY(a,b)

pull/1/head
Scott Lahteine 6 years ago
parent
commit
ca73b2f465
  1. 5
      Marlin/src/core/macros.h

5
Marlin/src/core/macros.h

@ -152,7 +152,10 @@
#define DECIMAL_SIGNED(a) (DECIMAL(a) || (a) == '-' || (a) == '+')
#define COUNT(a) (sizeof(a)/sizeof(*a))
#define ZERO(a) memset(a,0,sizeof(a))
#define COPY(a,b) memcpy(a,b,MIN(sizeof(a),sizeof(b)))
#define COPY(a,b) do{ \
static_assert(sizeof(a[0]) == sizeof(b[0]), "COPY: '" STRINGIFY(a) "' and '" STRINGIFY(b) "' types (sizes) don't match!"); \
memcpy(&a[0],&b[0],MIN(sizeof(a),sizeof(b))); \
}while(0)
// Macros for initializing arrays
#define ARRAY_6(v1, v2, v3, v4, v5, v6, ...) { v1, v2, v3, v4, v5, v6 }

Loading…
Cancel
Save