C ++“命名空间范围” [英] C++ "namespace scope"
问题描述
C ++规范( http:// www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf ,第7.5.4节)指出
链接规定只能在命名空间范围内发生
命名空间范围到底是什么意思?这是否意味着链接规范,如 externC
不能在全局范围内,只能在命名空间中?
这意味着 externC
应该只在命名空间范围(不是类范围,块范围等)。不在命名空间,但在全局范围 - 在全局命名空间范围。
$ b由
表示的潜在范围是一个original-namespace-name是由每个
命名空间所建立的声明区域的连接,在与原始命名空间名称相同的声明性区域中的定义。
The C++ spec (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf, section 7.5.4) states that
A linkage-specification shall occur only in namespace scope
What exactly does "namespace scope" mean? Does this mean that a linkage-specification, such as extern "C"
can't be in global scope, only in a namespace?
What exactly does "namespace scope" mean?
It means, that extern "C"
should be only in namespace-scope (not class-scope, block-scope etc.) Something, that is not in namespace, but is in global scope - is in global namespace scope.
The potential scope denoted by an original-namespace-name is the concatenation of the declarative regions established by each of the namespace-definitions in the same declarative region with that original-namespace-name.
这篇关于C ++“命名空间范围”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!