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:
Workaround A:
namespace linux { #include <ncurses.h> } // namespace linux using linux::max_align_t; // ncurses assumes it is in the global namespace #include <meta/meta.hpp>
compiles but will probably fail to link since the
ncurses
symbols are expected in the global namespace.Workaround B:
#include <ncurses.h> namespace cpp { #include <meta/meta.hpp> } // namespace cpp
is very brittle since it will only work as long as the
meta
library doesn't assume that any of its symbols are in the global namespace. That is, if the library needs to disambiguate internally a symbol and uses::meta::symbol_name
for that, this approach will break.