// C_ASSERT() can be used to perform many compile-time assertions: // type sizes, field offsets, etc. // An assertion failure results in error C2118: negative subscript. #define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
You might ask: How the hell does it work? Well, as the comments explain, it works by using a negative subscript (-1) in an array when the expressions to check for is false, which is of course invalid and will cause a compilation error, otherwise, if the expression is true, a positive subscript is used, which is alright. It does this by declaring (but not creating) an array with the size as the subscript.
Hope someone finds it useful.