What version of protobuf and what language are you using?
Version: master/v3.11.1 proto3 syntax.
Language: C++
What operating system (Linux, Windows, ...) and version?
Windows 10 Enterprise (v1909)
What runtime / compiler are you using (e.g., python version or gcc version)
vs2019 (v142), SDK 10.0.18362
What did you do?
Steps to reproduce the behavior:
Using globally defined names in enums in proto files conflicts with each other resulting in build errors. Here is an example:
Using the following enum type:
I can see that in the line constexpr AlarmSeverityProto AlarmSeverityProto_MAX = SEVERITY_ERROR;, SEVERITY_ERROR gets resolved to the global defined variable in winerror.h. I think this is weird behaviour as I would think the compiler would instead use the one defined in the namespace 🤷
Currently I have found 2 workarounds for this bug:
Do a #undef SEVERITY_ERROR before including the grpc/proto core header files mentioned above.
Insert the namespace of the enum in line constexpr AlarmSeverityProto AlarmSeverityProto_MAX = SEVERITY_ERROR; as the following constexpr AlarmSeverityProto AlarmSeverityProto_MAX = AlarmSeverityProto::SEVERITY_ERROR;
What did you expect to see
Expected it to use its own namespace defined enum instead of the global one.
What did you see instead?
It uses the global defined one.
Anything else we should know about your project / environment
Here is the error message I receive:
protolib_build_error.txt
What version of protobuf and what language are you using? Version: master/v3.11.1 proto3 syntax. Language: C++
What operating system (Linux, Windows, ...) and version? Windows 10 Enterprise (v1909)
What runtime / compiler are you using (e.g., python version or gcc version) vs2019 (v142), SDK 10.0.18362 What did you do? Steps to reproduce the behavior:
Using globally defined names in enums in proto files conflicts with each other resulting in build errors. Here is an example: Using the following enum type:
conflicts with a globally defined variable (SEVERITY_ERROR) defined in winerror.h which is included in one of the following header files:
Investigating the proto ph.h header file generated:
I can see that in the line
constexpr AlarmSeverityProto AlarmSeverityProto_MAX = SEVERITY_ERROR;
, SEVERITY_ERROR gets resolved to the global defined variable in winerror.h. I think this is weird behaviour as I would think the compiler would instead use the one defined in the namespace 🤷Currently I have found 2 workarounds for this bug:
#undef SEVERITY_ERROR
before including the grpc/proto core header files mentioned above.constexpr AlarmSeverityProto AlarmSeverityProto_MAX = SEVERITY_ERROR;
as the followingconstexpr AlarmSeverityProto AlarmSeverityProto_MAX = AlarmSeverityProto::SEVERITY_ERROR;
What did you expect to see
Expected it to use its own namespace defined enum instead of the global one.
What did you see instead?
It uses the global defined one.
Anything else we should know about your project / environment Here is the error message I receive: protolib_build_error.txt