13 lines
477 B
C
13 lines
477 B
C
// http://stackoverflow.com/questions/3385515/static-assert-in-c
|
|
#define STATIC_ASSERT(COND,MSG) typedef char static_assertion_##MSG[(!!(COND))*2-1]
|
|
// token pasting madness:
|
|
#define COMPILE_TIME_ASSERT3(X,L) STATIC_ASSERT(X,static_assertion_at_line_##L)
|
|
#define COMPILE_TIME_ASSERT2(X,L) COMPILE_TIME_ASSERT3(X,L)
|
|
#define COMPILE_TIME_ASSERT(X) COMPILE_TIME_ASSERT2(X,__LINE__)
|
|
|
|
COMPILE_TIME_ASSERT(sizeof(long)==8);
|
|
int main()
|
|
{
|
|
COMPILE_TIME_ASSERT(sizeof(int)==4);
|
|
}
|