Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top