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 <ypra...@gmail.com> 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 protobuf+unsubscr...@googlegroups.com.
> 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 protobuf+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/CADqAXr7LtL9QK2x3gM5xDvY8hCNHyNVT9yiTYRgPThLTUMQSfw%40mail.gmail.com.

Reply via email to