-
Notifications
You must be signed in to change notification settings - Fork 57
Description
Environment
- OS Version: NetBSD 10
- gz-msgs11 source build
Description
From the version.proto message, protoc generates a C++ class that defines int32_t major() const and int32_t minor() const member methods.
It happens that - at least on NetBSD - major(3) and minor(3) are macros defined in sys/types.h and the protoc generated code does not compile due to the macros exanding in the wrong context. These macros can be disabled from system headers by defining e.g. _POSIX_C_SOURCE at compile time, but defining this might have other unwanted side effects regarding system headers. It is also cumbersome to propagate this option to every single software that needs to include the message definitions.
On the NetBSD side, it will be very hard (not to say impossible) to change/rename these macros (as it was done e.g. on Linux) because they've always been there and the chances to break something somewhere are high.
My current workaround is to patch gz/msgs/convert/FuelMetadata.hh and the generated MessageTypes.hh by adding in the preambule before anything:
#include <sys/types.h>
#undef major
#undef minor
This is a bit fragile, and does not fix any code willing to include the messages directly.
So while noone is to blame really in this case, I was wondering whether it could possibly be envisaged to name those members a bit differently, like major_number or vmajor or anything not conflicting with system headers. I know this will break compatibility, but I was thinking that maybe this message is not widely used (only from fuel_metadata.proto from what I have seen so far) so it might not actually be that bad as a breaking change.
Any thoughts?
Metadata
Metadata
Assignees
Labels
Type
Projects
Status