Hello,
I am using VTK together with the Drogon C++ web framework.
Drogon depends on the system jsoncpp library, while VTK ships its own
vendored copy of jsoncpp under vtkjsoncpp (namespace vtkJson).
When both libraries are included in the same translation unit, I get
redefinition errors at compile time, for example:
In file included from /usr/local/include/drogon/plugins/SlashRemover.h:18,
from /usr/local/include/drogon/drogon.h:34,
from /home/site/merle/Projects/planet-sandbox/server/prototype_patients/patient_service/main.cc:3:
/usr/include/json/value.h:67:16: error: redefinition of 'class vtkJson::Exception'
67 | class JSON_API Exception : public std::exception {
| ^~~~~~~~~
In file included from /usr/local/include/drogon/HttpRequest.h:24,
from /usr/local/include/drogon/HttpBinder.h:25,
from /usr/local/include/drogon/HttpAppFramework.h:23,
from /usr/local/include/drogon/drogon.h:23,
from /home/site/merle/Projects/planet-sandbox/server/prototype_patients/patient_service/main.cc:3:
/usr/local/vtk-9.5.2-native/include/vtk-9.6/vtkjsoncpp/json/json.h:610:16: note: previous definition of 'class vtkJson::Exception'
610 | class JSON_API Exception : public std::exception {
| ^~~~~~~~~
In file included from /usr/local/include/drogon/plugins/SlashRemover.h:18,
from /usr/local/include/drogon/drogon.h:34,
from /home/site/merle/Projects/planet-sandbox/server/prototype_patients/patient_service/main.cc:3:
/usr/include/json/value.h:83:16: error: redefinition of 'class vtkJson::RuntimeError'
83 | class JSON_API RuntimeError : public Exception {
| ^~~~~~~~~~~~
In file included from /usr/local/include/drogon/HttpRequest.h:24,
from /usr/local/include/drogon/HttpBinder.h:25,
from /usr/local/include/drogon/HttpAppFramework.h:23,
from /usr/local/include/drogon/drogon.h:23,
from /home/site/merle/Projects/planet-sandbox/server/prototype_patients/patient_service/main.cc:3:
/usr/local/vtk-9.5.2-native/include/vtk-9.6/vtkjsoncpp/json/json.h:629:16: note: previous definition of 'class vtkJson::RuntimeError'
629 | class JSON_API RuntimeError : public Exception {
So I am wondering whether it would be better to rename the vtkJson namespace
directly instead of using a #define ?