[webkit-dev] "using namespace" style guideline
Chris Jerdonek
chris.jerdonek at gmail.com
Tue Nov 10 19:41:45 PST 2009
Hi, I have a question about the last of the WebKit Coding Style Guidelines:
http://webkit.org/coding/coding-style.html
It's the second of these two:
1. Any "using namespace" statements for a nested namespace whose
parent namespace is also defined in a file must be declared within
that namespace definition.
2. Any other "using namespace" statements must be declared before the
first namespace definition in the file.
Unlike most or all of the other rules, this one can affect
compilation. So I was wondering what the rule is for.
For example, say I want to write the following in an existing header
file to avoid having to fully qualify several identifiers in the WTF
namespace:
namespace MyNewNameSpace {
using namespace WTF;
// code
}
Following rule 2 and putting the using statement outside the namespace
can cause compilation errors elsewhere in the project (due to
ambiguous overloads for bringing the WTF namespace into files already
including the above). This actually happened to me while doing some
minor refactoring.
If I want to keep the "using namespace" statement, it seems like the
style guideline would require me to do an unknown amount of
refactoring outside the file.
Let me know your thoughts.
Thanks,
--Chris
More information about the webkit-dev
mailing list