Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protoc: c++ windows #defines IN, OUT, and OPTIONAL to empty strings #7076

Closed
scotthart opened this issue Jan 10, 2020 · 5 comments · Fixed by #7087
Closed

protoc: c++ windows #defines IN, OUT, and OPTIONAL to empty strings #7076

scotthart opened this issue Jan 10, 2020 · 5 comments · Fixed by #7087

Comments

@scotthart
Copy link
Contributor

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

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

What runtime / compiler are you using (e.g., python version or gcc version)
msvc

What did you do?
including field_behavior.pb.h generated from https://github.com/googleapis/googleapis/blob/c9dce519127b97e866ca133a01157f4ce27dcceb/google/api/field_behavior.proto#L57 in other files results in a malformed enum definition for google::api::FieldBehavior

What did you expect to see
field_behavior.pb.h was emitted containing:

enum FieldBehavior {
  FIELD_BEHAVIOR_UNSPECIFIED = 0,
  OPTIONAL = 1,
  REQUIRED = 2,
  OUTPUT_ONLY = 3,
  INPUT_ONLY = 4,
  IMMUTABLE = 5,
  FieldBehavior_INT_MIN_SENTINEL_DO_NOT_USE_ = std::numeric_limits<::google::protobuf::int32>::min(),
  FieldBehavior_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits<::google::protobuf::int32>::max()
};

What did you see instead?
When included after <windows.h> the resulting .i file contains:

enum FieldBehavior : int {
  FIELD_BEHAVIOR_UNSPECIFIED = 0,
   = 1,
  REQUIRED = 2,
  OUTPUT_ONLY = 3,
  INPUT_ONLY = 4,
  IMMUTABLE = 5,
  FieldBehavior_INT_MIN_SENTINEL_DO_NOT_USE_ = std::numeric_limits<::google::protobuf::int32>::min(),
  FieldBehavior_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits<::google::protobuf::int32>::max()
};

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).
Code example: https://godbolt.org/z/W_zBzC
The offending header is minwindef.h https://github.com/tpn/winsdk-10/blob/9b69fd26ac0c7d0b83d378dba01080e93349c2ed/Include/10.0.10240.0/shared/minwindef.h#L87
Notice it also #defines IN and OUT to empty strings as well.

Anything else we should know about your project / environment

@egorpugin
Copy link
Contributor

I also have the same issue with ERROR.
Should I open a PR?

@rafi-kamal
Copy link
Contributor

rafi-kamal commented Feb 2, 2020

#7088 fixes it. It should be available in the 3.11.3 release.

@egorpugin
Copy link
Contributor

I don't see ERROR macro or whatever there.

@rafi-kamal
Copy link
Contributor

Oh alright - please free to create a PR and send it to @acozzette.

@egorpugin
Copy link
Contributor

@rafi-kamal See #7168

sthagen added a commit to sthagen/protocolbuffers-protobuf that referenced this issue Feb 23, 2020
bug: protocolbuffers#7076 adds ERROR to windows portability files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants