C++ 规范( http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf ,第 7.5.4 节)指出
A linkage-specification shall occur only in namespace scope
“命名空间范围”到底是什么意思?这是否意味着链接规范(例如 extern "C"
)不能在全局范围内,只能在命名空间中?
“命名空间范围”到底是什么意思?
最佳答案
这意味着,extern "C"
应该只在命名空间范围内(而不是类范围、 block 范围等)。某些东西,不在命名空间内,但在全局范围内- 位于全局命名空间范围内。
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++ "namespace scope",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19541086/