Bruce Eckel says in "Thinking in C++":
"If you put local names in an unnamed namespace, you don’t
need to give them internal linkage by making them static. C++
deprecates the use of file statics in favor of the unnamed
namespace."
And you say they have still external linkage. However, we
can't use(reach) them in an another module?
Unless you're compiler supports export
. (Even then, it's not
clear what "another module" means---but you can instantiate a
template over a symbol defined in an unnamed namespace, even if
the implementation code of the template was exported, and thus
in "another module".)
Seriously, an unnamed namespace works exactly like any other
namespace: a defined symbol (regardless of what) follows no
special rules just because the namespace is unnamed. In theory,
at least, the symbol is fully visible in all translation units.
Except that you can't name the namespace which contains it, so
you have no way of getting at it. (In practice, compilers don't
make any distinction whatsoever, and giving an internally
generated name to an unnamed namespace. Taking pains to ensure
that it's not one you might use, and that it won't be the same
in different translation units.)
Would you mind if I asked to expain what Mr. Ecker wanted to
say?
He probably wanted to say exactly what he said: if you put names
in an unnamed namespace, you don't need to give them internal
linkage, because the fully qualified name can't be referred to
from a different translation unit. (At least by a coder---as I
said, it can be seen when instantiating an exported template on
it, and depending on how export is implemented, or your point of
view, that can be considered a different translation unit.)
Part of the motivation behind introducing unnamed namespace is
related to templates. (Another part is that you have no means
of giving things like class names internal linkage, so some
other technique had to be introduced to make them invisible in
other translation units.)