File: compiletimeassert.h

package info (click to toggle)
libowfat 0.34-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,288 kB
  • sloc: ansic: 20,181; makefile: 16
file content (22 lines) | stat: -rw-r--r-- 565 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

#ifdef __clang__

// clang already includes the condition in the error message and emits
// an additional warning here if we use the variant without message
#define compiletimeassert(cond) _Static_assert(cond,"")

#elif __STDC_VERSION__ >= 201710L

#define compiletimeassert(cond) _Static_assert(cond,#cond)

#elif __STDC_VERSION__ >= 201112L

#define compiletimeassert(cond) _Static_assert(cond,#cond)

#else

#define __X(x, y) x ## y
#define __Y(x, y) __X(x, y)
#define compiletimeassert(cond) struct __Y(foo,__LINE__) { char __temp[1 - (!(cond))*2]; };

#endif