From the C++11 standard point of view, is there a technical difference of object status/properties between:
namespace
{
int foo;
const int bar = 42;
}
and
namespace
{
static int foo;
static const bar = 42;
}
?
From questions and answers around here I was believing that objects in anonymous namespace were implicitly static, but someone tell me it’s the linkage only that’s internal, the compiler will not take the object as if it was marked static with implications like how it will implement object construction. So I need some details about what it really means, if there is a difference between with and without static in anonymous namespace.
C++11, 3.5/4:
So in C++11 both of your
fooobjects have internal linkage. In C++03, the first one has external linkage.Regardless of linkage, it has static storage duration.
I don’t think there’s any such thing in the standard as “take the object as if it was marked static”, so I can’t answer to that. If you find some text in the standard that refers to whether the object is “marked static” and doesn’t refer specifically to either linkage or storage duration, then cite it and I can give you an opinion 🙂