[sigc] "using namespace xxx" is asking for name clashes, even more so with C++11



Recent versions of libsigc++, glibmm, gtkmm, etc. require C++11. With C++11 the standard library contains many new classes and functions. Lazy application programmers who don't want to write the names of namespaces again and again, instead write e.g.

  using namespace std;
  using namespace sigc;
  using namespace Glib;
  using namespace Gtk;

If you do that, you're likely to get in trouble, when you enable your compiler's C++11 features, because suddenly the STL header files declare many new symbols. The compiler's error messages may or may not point you in the right direction. If you're lucky, you will be told that a function call is ambiguous. If not, the compiler will e.g. silently choose std::bind() (new in C++11), when you tried to call sigc::bind(), but didn't write sigc::. But then the compiler won't be silent any more. The functor that std::bind() returns probably doesn't fit into the rest of your code, and you may get very cryptic error messages.

Several application programs have met with new name clashes. See e.g.
https://bugzilla.gnome.org/show_bug.cgi?id=759732
https://bugzilla.gnome.org/show_bug.cgi?id=755750, especially comment 9



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]