为什么需要将全局匿名联合声明为静态? [英] Why are global anonymous unions required to be declared as static?

查看:33
本文介绍了为什么需要将全局匿名联合声明为静态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C++ 0x 草稿

9.5.6 在命名命名空间或全局命名空间中声明的匿名联合应声明为静态.

9.5.6 Anonymous unions declared in a named namespace or in the global namespace shall be declared static.

这是为什么?

推荐答案

我的猜测是,如果允许以非静态方式定义联合,它可能会违反 ODR(一个定义规则)

My guess is that if it were allowed to define the union in a non static way it may violate the ODR (one definition rule)

这篇关于为什么需要将全局匿名联合声明为静态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆