这应该是完全合法的。需要注意的是,C里面的作用域规则。
6.2.1 Scopes of identifiers
2 ... There are four kinds of scopes: function, file, block, and
function prototype. (A function prototype is a declaration of a
function that declares the types of its parameters.)
3 A label name is the only kind of identifier that has function scope.
It can be used (in a goto statement) anywhere in the function in
which it appears, and is declared implicitly by its syntactic
appearance (followed by a : and a statement).
4 Every other identifier has scope determined by the placement of its
declaration (in a declarator or type specifier). If the declarator
or type specifier that declares the identifier appears outside of
any block or list of parameters, the identifier has file scope,
which terminates at the end of the translation unit. If the
declarator or type specifier that declares the identifier appears
inside a block or within the list of parameter declarations in a
function definition, the identifier has block scope, which
terminates at the end of the associated block.
根据这些规则,aastruct、ccstruct和struct BB具有相同的作用域。如果定义
在一个块(如函数)外面的话,这些名字具有文件作用域。
当然这个风格并不好。名字也很糟糕:aastruct和ccstruct是类型,而bbstruct
是个结构成员的名字。
2013/5/16 kuyuxin zhang <
zyongx...@gmail.com>:
> --
> -- You received this message because you are subscribed to the Google Groups
> Shanghai Linux User Group group. To post to this group, send email to
>
sh...@googlegroups.com. To unsubscribe from this group, send email to
>
shlug+un...@googlegroups.com. For more options, visit this group at
>
https://groups.google.com/d/forum/shlug?hl=zh-CN
> ---
> 您收到此邮件是因为您订阅了 Google 网上论坛的“Shanghai Linux User Group”论坛。
> 要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到
shlug+un...@googlegroups.com。
> 要查看更多选项,请访问
https://groups.google.com/groups/opt_out。
>
>
--
Wu Yongwei
URL:
http://wyw.dcweb.cn/