Skip to content

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

Closed

Description

@scotthart

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

Activity

  1. added 2 commits that reference this issue on Jan 13, 2020
  2. added 2 commits that reference this issue on Jan 13, 2020
  3. egorpugin commented on Feb 2, 2020

    @egorpugin
    Contributor

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

  4. rafi-kamal commented on Feb 2, 2020

    @rafi-kamal
    Contributor

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

  5. egorpugin commented on Feb 2, 2020

    @egorpugin
    Contributor

    I don't see ERROR macro or whatever there.

  6. rafi-kamal commented on Feb 2, 2020

    @rafi-kamal
    Contributor

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

  7. egorpugin commented on Feb 2, 2020

    @egorpugin
    Contributor
  8. added a commit that references this issue on Feb 21, 2020
  9. added a commit that references this issue on Feb 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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