Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Unable to compile protobufs in pb namespace #8349

@rowillia

Description

@rowillia

In Nov 2020 protobuf reserved the namespace pb for protobuf to move to in the future (

// Protobuf intends to move into the pb:: namespace.
namespace protobuf_future_namespace_placeholder {}
namespace pb = ::protobuf_future_namespace_placeholder;
). This is very problematic for us as all of our protobufs are in the pb namespace and breaks our ability to upgrade. This seems to be quite a common pattern in the industry - there's over 10k examples on github alone - https://github.com/search?l=Protocol+Buffer&p=1&q=%22package+pb%22&type=Code .

If at all possible can we roll back that change? I suspect it has the potential to break a huge number of users beyond just us.

What version of protobuf and what language are you using?
Version: 3.15.0
Language: C++

What operating system (Linux, Windows, ...) and version?
OSX

What runtime / compiler are you using (e.g., python version or gcc version)
clang --version
Apple clang version 12.0.0 (clang-1200.0.32.28)
Target: x86_64-apple-darwin19.6.0
Thread model: posix

What did you do?
Steps to reproduce the behavior:

Create file pb/people/models/people.proto:

syntax = "proto3";

package pb.people.models;

message Person {
  string name = 1;
  int32 id = 2;
  string email = 3;
}
protoc -I. --cpp_out=. pb/people/models/people.proto
clang -g -fwrapv -O3 -Wall -I. -I /usr/local/include/ -c pb/people/models/people.pb.cc -o a.o -std=c++11

What did you expect to see
No output, Code compiles

What did you see instead?

./pb/people/models/people.pb.h:57:11: error: redefinition of 'pb' as different kind of symbol
namespace pb {
          ^
../cytobuf/third_party/protobuf/src/google/protobuf/port.h:44:11: note: previous definition is here
namespace pb = ::protobuf_future_namespace_placeholder;
          ^
In file included from pb/people/models/people.pb.cc:4:
./pb/people/models/people.pb.h:70:18: error: no member named 'people' in namespace 'protobuf_future_namespace_placeholder'
template<> ::pb::people::models::Person* Arena::CreateMaybeMessage<::pb::people::models::Person>(Arena*);
           ~~~~~~^
./pb/people/models/people.pb.h:70:74: error: no member named 'people' in namespace 'protobuf_future_namespace_placeholder'
template<> ::pb::people::models::Person* Arena::CreateMaybeMessage<::pb::people::models::Person>(Arena*);
...
...

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Anything else we should know about your project / environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions