I have been using the static
keyword a long time for defining internal linkage. Later, I switched to the C++ style of wrapping local things in anonymous namespaces.
However, now when I have worked with anonymous namespaces for some years, I start to think that static
keyword is a lot easier to work with!
A common problem is that I have this pattern:
namespace {
// ...five pages of code...
} // namespace
To see if a certain function has internal or external linkage, I now have to scroll a lot, as opposed to the old C style where I could just check if the function/object had static
in front of it.
I know there are things anonymous namespaces do that static
can't - hide typedefs - but personally I'm not really very interested in that, anyway.
What are your take on this? Is the win of anonymous namespaces that great that it warrants the decreased readability? Or am I all out wrong?