c++linuxnamespacesname-collision

Name collision between c++ library namespace and C linux function


The Linux <ncurses.h> header defines the function meta, and the C++ metaprogramming library meta puts all its code in the global namespace meta.

How can I use both in the same C++ program (not necessarily the same TU but that would be nice)? Is there a way to work around the name collision?

I can think of two brittle workarounds, but they are easy to break:


Solution

  • I would suggest workaround C: Isolate your code such that the meta library use and the ncurses use are in separate translation units in your project. This way in any particular translation unit there isn't one symbol being used as both a namespace and a global function.