Hello friends,
My company uses Protobuf as a shared library. I know that Google recommends linking Protobuf statically, especially if it is used by a shared library, but that is not an option in my case, for reasons that are beyond my control. As a result of dynamic linking, I am encountering Protobuf versions clash, when a third-party software uses a different version of Protobuf than my company does.
In order to isolate the third-party software from "our" version of Protobuf, I would like to wrap our version into an additional namespace. I found out that in the Protobuf file google/protobuf/port_def.inc, there exists a preprocessor symbols PROTOBUF_NAMESPACE, PROTOBUF_NAMESPACE_ID, and PROTOBUF_NAMESPACE_OPEN, which I could re-define. For instance,
#define PROTOBUF_NAMESPACE_ID google::protobuf
can be replaced with
#define PROTOBUF_NAMESPACE_ID myNamespace::google::protobuf
I know that the above preprocessor symbol is _not_ consistently used through the Protobuf source files, but in principle it looks like it is not very hard to make the corresponding adjustments.
Has anybody tried that? What were the difficulties you encountered?
Many thanks is advance!
-Yakov