A (file-local; .cpp) const-qualified variable declared at namespace-scope has internal linkage and is thus translation unit local. Is there any reason to/effect of still wrapping the constant in an anonymous namespace?
E.g., is there any reason to prefer any of the following two over the other, and if so, why?
// file.cpp
namespace foo {
const int kMyLocalConstant = 42; // internal linkage
} // namespace foo
vs
// file.cpp
namespace foo {
namespace {
const int kMyLocalConstant = 42; // internal linkage
} // namespace
} // namespace foo
I'm grateful to get answers for C++03 as well as C++11, if there is any different in-between the two for this context.
Possible duplicates
I have read the excellent answer to
but I don't see it answering my specific question (please correct me if I'm wrong), as the answer focuses on non-const variable identifiers and non-static free functions. My question focuses on file-local namespace-scoped constants, i.e., variable identifiers which already have internal linkage. Maybe there is a more appropriate dupe that I haven't found.