C++ “namespace scope”

怎甘沉沦 提交于 2019-12-02 02:23:31

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/19541086/c-namespace-scope

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!