In what scope is a struct member identifier put?

前端 未结 4 1769
南方客
南方客 2021-01-18 10:25

The C spec says

There are four kinds of scopes: function, file, block, and function prototype.

Now if I do the following outside any

4条回答
  •  天涯浪人
    2021-01-18 11:20

    As the standard says, it's in a separate name space created for the struct type. This rule was added in C89, I think. Once upon a time, all member names shared a single name space.

    Maybe the compiler writer was being pedantic; a name space is not the same as a scope. A struct definition does not introduce a scope as it doesn't hold variables; it holds members.

提交回复
热议问题