fork download
  1.  
  2. typedef struct
  3. {
  4. int bla_u32;
  5. short bla_u16;
  6. char bla_u8;
  7.  
  8. /* <-- this gap will be filled in the unpacked version */
  9. } uneven;
  10.  
  11. #define StaticAssert(cond, msg) switch(0){case 0:case cond:;}
  12.  
  13. void checkSizes()
  14. {
  15. uneven unpacked;
  16. #pragma pack(push, 1)
  17. typedef struct
  18. {
  19. int bla_u32;
  20. short bla_u16;
  21. char bla_u8;
  22.  
  23. /* <-- this gap will be filled in the unpacked version */
  24. } uneven;
  25. #pragma pack(pop)
  26. uneven packed;
  27. StaticAssert(sizeof(unpacked) == sizeof(packed), "uneven contains gaps");
  28. }
  29.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function 'checkSizes':
prog.c:11:50: error: duplicate case value
 #define StaticAssert(cond, msg) switch(0){case 0:case cond:;}
                                                  ^
prog.c:27:3: note: in expansion of macro 'StaticAssert'
   StaticAssert(sizeof(unpacked) == sizeof(packed), "uneven contains gaps");
   ^
prog.c:11:43: error: previously used here
 #define StaticAssert(cond, msg) switch(0){case 0:case cond:;}
                                           ^
prog.c:27:3: note: in expansion of macro 'StaticAssert'
   StaticAssert(sizeof(unpacked) == sizeof(packed), "uneven contains gaps");
   ^
stdout
Standard output is empty