fork download
  1. #include <stddef.h>
  2.  
  3. #define C_ASSERT(expr) extern char CAssertExtern[(expr)?1:-1]
  4.  
  5. // You keep this definition private to module A (e.g. in a .c file):
  6. typedef struct
  7. {
  8. int A;
  9. int B;
  10. int C[4];
  11. } PrivateStruct;
  12.  
  13. // You expose this definition to all modules (in an .h file):
  14. typedef struct
  15. {
  16. char reserved[2*sizeof(int)];
  17. int C[4];
  18. } PublicStruct;
  19.  
  20. // You put these in module A (in a .c file):
  21. C_ASSERT(sizeof(PrivateStruct) == sizeof(PublicStruct));
  22. C_ASSERT(offsetof(PrivateStruct,C) == offsetof(PublicStruct,C));
  23.  
  24. int main(void)
  25. {
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0.01s 1672KB
stdin
Standard input is empty
stdout
Standard output is empty