• mina86@lemmy.wtf
    link
    fedilink
    English
    arrow-up
    8
    ·
    edit-2
    1 day ago

    Minor correction: Unnamed structs and unions (so your second example) are not part of C. They are GNU extensions.

    • MinekPo1 [it/she]@lemmygrad.ml
      link
      fedilink
      arrow-up
      3
      ·
      edit-2
      2 days ago

      “ANSI C” by Kernighan and Ritchie disagrees , including that syntax (note : retranslation from Polish as that’s the language my copy is in) :

      A8.3

      […]

      struct-union-specifier:
      , union-struct identifier ₒₚₜ { compound-declaration-list }
      , union-struct identifier

      […]

      Specifiers of structures or unions with [a compound declaration] list, but with no label [identifier], creates a unique type; it may only be referred to in the declaration in which it is part.

      • mina86@lemmy.wtf
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 day ago

        Yes, but I was talking about field name, not struct tag. And up to C99 my comment was correct.