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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top