Internals: Use static_assert

This commit is contained in:
Wilson Snyder 2021-02-23 19:02:04 -05:00
parent 8c2ee6c5ab
commit a886f28c85

View File

@ -45,18 +45,12 @@
constexpr unsigned VL_VALUE_STRING_MAX_WIDTH = 8192;
//===========================================================================
// Static sanity checks (when get C++11 can use static_assert)
// Static sanity checks
typedef union {
// cppcheck-suppress unusedStructMember // Unused as is assertion
char vluint8_incorrect[(sizeof(vluint8_t) == 1) ? 1 : -1];
// cppcheck-suppress unusedStructMember // Unused as is assertion
char vluint16_incorrect[(sizeof(vluint16_t) == 2) ? 1 : -1];
// cppcheck-suppress unusedStructMember // Unused as is assertion
char vluint32_incorrect[(sizeof(vluint32_t) == 4) ? 1 : -1];
// cppcheck-suppress unusedStructMember // Unused as is assertion
char vluint64_incorrect[(sizeof(vluint64_t) == 8) ? 1 : -1];
} vl_static_checks_t;
static_assert(sizeof(vluint8_t) == 1, "vluint8_t is missized");
static_assert(sizeof(vluint16_t) == 2, "vluint8_t is missized");
static_assert(sizeof(vluint32_t) == 4, "vluint8_t is missized");
static_assert(sizeof(vluint64_t) == 8, "vluint8_t is missized");
//===========================================================================
// Global variables