Thank you very much for your answer. You've also answered my second question, confirming my observation that there is a cyclical dependency between Protoc and some generated *.pb.cc and *.pb.h files -- in particular, descriptor.pb.c. If I add an extra namespace around google::protobuf, how am I supposed to go about descriptor.pb.cc? -- Indeed, I need an updated version of descriptor.pb.cc in order to generate the updated protoc.exe, but how do I generate the new descriptor.pb.cc without first having the updated protoc.exe?
Many thanks in advance, -Yakov On Friday, September 18, 2020 at 11:26:38 AM UTC-4 [email protected] wrote: > I think this will work if you change the namespace everywhere, but the one > caveat is that protobuf messages won't be interchangeable between the two > protobuf versions. I.e. if you try to take a proto based on your > myNamespace version and pass it to code that works with the version used by > your third-party software, that will likely cause problems. If you are able > to keep them separate then it should work, though. > > On Thu, Sep 17, 2020 at 6:13 PM Yakov Prager <[email protected]> wrote: > >> >> 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 >> >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Protocol Buffers" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/protobuf/e174deee-c87e-4fd1-910c-2a22a707af58n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/protobuf/e174deee-c87e-4fd1-910c-2a22a707af58n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/decbe788-18d3-42cd-a765-06aeda47591an%40googlegroups.com.
