Dealing with message name collisions between unrelated .proto files

26 views
Skip to first unread message

Martin

unread,
Sep 21, 2022, 2:18:15 PMSep 21
to Protocol Buffers
Hi,

I have two different .proto files (say foo.proto and bar.proto) for different services where both use the package name internal and both define a ToService message. I need to use both protocols from the same program, but when I try to do that, I get duplicate symbol linker errors; both define internal::ToService::~ToService and other symbols in the internal:: namespace.

I would really, really prefer to not have to modify the .proto files, since my project just tries to interact with existing services. How do I tell protoc to generate code in a different namespace than internal?

sh...@google.com

unread,
Sep 23, 2022, 3:50:27 PMSep 23
to Protocol Buffers
Unfortunately this violates the one definition rule. That simply means you have two identical C++ classes loaded. I guess you have to resolve the package/message name for one of them.
Reply all
Reply to author
Forward
0 new messages