I use the C library (libgretl) from C ++, and some of its functions conflict with my code, so I would like to wrap it in a namespace, for example:
namespace libgretl { extern "C" { #include <gretl/libgretl.h> }}
However, this does not compile, I get "undefined" errors from gcc files (using mingw32 with gcc 4.5.2 on Windows). The first errors come from the following block of C ++ / cstddef file code:
_GLIBCXX_BEGIN_NAMESPACE(std) using ::ptrdiff_t; using ::size_t; _GLIBCXX_END_NAMESPACE
where macros expand accordingly to namespace std { and } . After that, more errors appear.
Omitting the extern "C" directive does not help. Using an anonymous namespace reduces errors, but it still wonβt compile.
So my question is, is there a way to include such a C library and put its functions in the namespace without modifying the gcc source files or libraries?
Thanks.
Michal
source share