'using namespace' considered harmful
Guys, I've been noticing a lot of usage of 'using namespace' starting to creep into the codebase. With few exceptions, that's not a good thing...
The reason is that as more classes get added to the imported namespace, a class or function may eventually get added that conflicts with one in your own namespace.
Depending on the exact nature of the conflict, it may not result in a compile failure, but instead introduce subtle bugs into the compiled code (e.g. if overload resolution picks the wrong function).
So, as a rule, please 'using' the individual classes or functions that you actually need. Do NOT 'using' an entire namespace, and especially DO NOT use any form of 'using' in the global scope of a header file -- that will pollute the namespace of every file that directly or indirectly includes your header.
Current offenders:
(header files with inappropriate 'using's that MUST be fixed) src/ui/dialog/align-and-distribute.h:using namespace Inkscape::UI::Widget; src/ui/dialog/document-preferences.h:using namespace Inkscape::UI::Widget; src/ui/dialog/export.h:using namespace Inkscape::UI::Widget; src/ui/dialog/fill-and-stroke.h:using namespace Inkscape::UI::Widget; src/ui/dialog/find.h:using namespace Inkscape::UI::Widget; src/ui/dialog/inkscape-preferences.h:using namespace Inkscape::UI::Widget; src/ui/dialog/messages.h:using namespace Inkscape::UI::Widget; src/ui/dialog/text-properties.h:using namespace Inkscape::UI::Widget; src/ui/widget/unit-menu.h:using namespace Inkscape::Util;
(modules where individual 'using's would be better) src/ui/dialog/inkscape-preferences.cpp:using namespace Inkscape::UI::Widget; src/ui/stock-items.cpp: using namespace Gtk::Stock; src/application/editor-impl.cpp:using namespace Inkscape::UI; src/application/editor-impl.cpp:using namespace Inkscape::UI::Widget; src/io/ftos.cpp:using namespace std; src/svg/ftos.cpp:using namespace std; src/svg/itos.cpp:using namespace std;
Please fix, thanks.
-mental
participants (1)
-
MenTaLguY