fork(1) download
  1. #define BUILD_BUG_OR_ZERO(e) (sizeof(struct{ int:-!!(e);}))
  2. #define ENSURE_EVEN_SIZE(e) BUILD_BUG_OR_ZERO((sizeof(e) % 2 == 1))
  3.  
  4. struct uneven{
  5. char a,b,c;
  6. };
  7.  
  8. struct even{
  9. char a,b,c,d;
  10. };
  11.  
  12. int main(){
  13. ENSURE_EVEN_SIZE(struct even);
  14. /* compiler error: */
  15. ENSURE_EVEN_SIZE(struct uneven);
  16. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘main’:
prog.c:1:30: warning: statement with no effect [-Wunused-value]
 #define BUILD_BUG_OR_ZERO(e) (sizeof(struct{ int:-!!(e);}))
                              ^
prog.c:2:29: note: in expansion of macro ‘BUILD_BUG_OR_ZERO’
 #define ENSURE_EVEN_SIZE(e) BUILD_BUG_OR_ZERO((sizeof(e) % 2 == 1))
                             ^
prog.c:13:3: note: in expansion of macro ‘ENSURE_EVEN_SIZE’
   ENSURE_EVEN_SIZE(struct even);
   ^
prog.c:15:27: error: negative width in bit-field ‘<anonymous>’
   ENSURE_EVEN_SIZE(struct uneven);
                           ^
prog.c:1:54: note: in definition of macro ‘BUILD_BUG_OR_ZERO’
 #define BUILD_BUG_OR_ZERO(e) (sizeof(struct{ int:-!!(e);}))
                                                      ^
prog.c:15:3: note: in expansion of macro ‘ENSURE_EVEN_SIZE’
   ENSURE_EVEN_SIZE(struct uneven);
   ^
prog.c:1:30: warning: statement with no effect [-Wunused-value]
 #define BUILD_BUG_OR_ZERO(e) (sizeof(struct{ int:-!!(e);}))
                              ^
prog.c:2:29: note: in expansion of macro ‘BUILD_BUG_OR_ZERO’
 #define ENSURE_EVEN_SIZE(e) BUILD_BUG_OR_ZERO((sizeof(e) % 2 == 1))
                             ^
prog.c:15:3: note: in expansion of macro ‘ENSURE_EVEN_SIZE’
   ENSURE_EVEN_SIZE(struct uneven);
   ^
prog.c:16:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
stdout
Standard output is empty