• Obin@feddit.org
      link
      fedilink
      arrow-up
      19
      ·
      edit-2
      4 days ago

      You mean ‘unnamed’ is what’s confusing you?

      Normally you can do anonymous struct/union members or struct struct/union members that are tagged structs but not anonymous.

      I.e. in standard C you’d have to do either:

      struct foo { int baz; };
      struct bar { struct foo foo; };
      ...
      struct bar data;
      data.foo.baz = 0;
      

      or:

      struct bar { struct {  int baz; } foo; };
      ...
      struct bar data;
      data.baz = 0;
      

      but to do the following, you’d need the extension:

      struct foo { int baz; };
      struct bar { struct foo; };
      ...
      struct bar data;
      data.baz = 0;
      
    • mina86@lemmy.wtf
      link
      fedilink
      English
      arrow-up
      13
      ·
      edit-2
      4 days ago

      Tag is what goes after the struct keyword to allow referring to the struct type. Structs don’t have to have a tag. Name is what field are called. Adapting Obin’s example:

      struct foo { int baz; };
      struct bar { struct foo qux; };
      struct bar data;
      data.qux.baz = 0;
      

      foo and bar are tags for struct foo and struct bar types respectively; baz and qux are field names; and data is a variable name.