Checks assertions at compile time.
An expression that can be determined at compile time.
If the assertion succeeds, the expression evaluates to
typedef char __C_ASSERT__;, which the compiler will accept.
If the assertion fails, the expression evaluates to
typedef char __C_ASSERT__[-1];, which results in a compilation error because negative subscripts are not valid.
The C_ASSERT macro is defined as follows.
The following examples demonstrate common types of compile-time assertions.
C_ASSERT (BUFFER_CCH_SIZE <= MAX_PATH); C_ASSERT (ARRAYSIZE(array1) == ARRAYSIZE(array2)); C_ASSERT (FIELD_OFFSET(STRUCT_DEF, MemberName) == 0x1d4); C_ASSERT (sizeof(BOOLEAN) == sizeof(UCHAR));