boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

109-typedef-anon.c (439B)


      1 /* Anonymous struct via typedef (the form tcc.c uses for many types).
      2  * No struct tag, only a typedef name. */
      3 
      4 typedef struct {
      5     int x;
      6     int y;
      7 } Point;
      8 
      9 Point make(int a, int b) {
     10     Point p;
     11     p.x = a;
     12     p.y = b;
     13     return p;
     14 }
     15 
     16 int main(int argc, char **argv) {
     17     Point a;
     18     a.x = 3;
     19     a.y = 4;
     20     if (a.x + a.y != 7) return 1;
     21 
     22     Point b = make(10, 20);
     23     if (b.x != 10 || b.y != 20) return 2;
     24     return 0;
     25 }