fork download
  1. /* Example 1, tagless */
  2.  
  3. #define mystruct1 struct { int x; }
  4.  
  5. /* 'foo1' and 'bar1' have the same type. 'baz1' does not */
  6. mystruct1 foo1, bar1;
  7. mystruct1 baz1;
  8.  
  9. /* Example 2, with a tag */
  10.  
  11. struct tag2 { int x; };
  12. #define mystruct2 struct tag2
  13.  
  14. /* 'foo2', 'bar2', 'baz2' all have the same type */
  15. mystruct2 foo2, bar2;
  16. mystruct2 baz2;
  17.  
  18. /* Example 3, tagless, but with a typedef */
  19.  
  20. typedef struct { int x; } mystruct3;
  21.  
  22. /* 'foo3', 'bar3', 'baz3' all have the same type */
  23. mystruct3 foo3, bar3;
  24. mystruct3 baz3;
  25.  
  26. /* Example 4, with a tag and with a typedef */
  27.  
  28. typedef struct tag4 { int x; } mystruct4;
  29.  
  30. /* 'foo4', 'bar4', 'baz4' all have the same type */
  31. mystruct4 foo4, bar4;
  32. mystruct4 baz4;
  33.  
  34. int main(void) { return 0; }
Success #stdin #stdout 0.01s 1716KB
stdin
Standard input is empty
stdout
Standard output is empty