C++ conflicting namespaces -
i developing c++ project in prj_cpp.h starts as
// prj_cpp.h #include "lib_cpp.h" extern "c" { #include "lib_c.h" } where lib_cpp.h , lib_c.h header files of external c++ , c libraries respectively.
external c++ library lib_cpp.h uses lib_c in following way.
// lib_cpp.h namespace some_weird_namespace { extern "c" { #include "lib_c.h" } } because lib_c.h prevents double inclusion, turns out objects in lib_c.h reside in some_weird_namespace has nothing project prj_cpp.
on other hand if header file looks like
// prj_cpp.h extern "c" { #include "lib_c.h" } #include "lib_cpp.h" i break external c++ project because there nothing under some_weird_namespace because include lib_c.h first.
i not allowed modify neither lib_cpp.h nor lib_c.h
is there can in prj_cpp.h resolve such issue?
i not using some_weird_namespace in project because namespace has nothing it. moreover, number of lib_c.h headers files can large.
if use lib_cpp.h more lib_c.h, replace #include lib_c.h following wrapper:
// lib_c_wrapper.h namespace some_weird_namespace { extern "c" { #include "lib_c.h" } } if use lib_c.h more lib_cpp.h use following wrapper:
// lib_cpp_wrapper.h #define some_weird_namespace your_namespace #include "lib_cpp.h" this workaround solve problem.
Comments
Post a Comment