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

Make _grpc.h types C++20 compatible #1041

Merged
merged 4 commits into from
May 18, 2020

Conversation

chwarr
Copy link
Member

@chwarr chwarr commented May 16, 2020

As of C++20, it is malformed to have an unnamed class used in typedef with a
base class. In the generated reflection code for a service, we were using the
following construct to create a reflectable entry for each field in a
struct.

struct service {
    typedef struct /* no name */ : ::bond::reflection::MethodTemplate<...> {} method_name;
}

Now, instead of using an unnamed class, we generate a named class and refer
to that:

struct service {
    typedef struct method_name_type : ::bond::reflection::MethodTemplate<...> {} field_name;
}

This commit is very similar in spirit to f1cb707. See that commit for
even more details about what's going on.

Also adds a test that compiles a service that has method names that
conflict with the names in MethodTemplate. The gRPC++ unit test CMake
now has a single library with the compiled generated code.

Fixes #1027

As of C++20, it is malformed to have an unnamed class used in typedef with a
base class. In the generated reflection code for a service, we were using the
following construct to create a reflectable entry for each field in a
struct.

```
struct service {
    typedef struct /* no name */ : ::bond::reflection::MethodTemplate<...> {} method_name;
}
```

Now, instead of using an unnamed class, we generate a named class and refer
to that:

```
struct service {
    typedef struct method_name_type : ::bond::reflection::MethodTemplate<...> {} field_name;
}
```

This commit is very similar in spirit to f1cb707. See that commit for
even more details about what's going on.

Also adds a test that compiles a service that has method names that
conflict with the names in `MethodTemplate`. The gRPC++ unit test CMake
now has a single library with the compiled generated code.

Fixes microsoft#1027
@chwarr
Copy link
Member Author

chwarr commented May 16, 2020

@BertusGreeff, can you help review this? It's very similar to your PR #1028.

@chwarr
Copy link
Member Author

chwarr commented May 16, 2020

This will probably need to be merged with #1039 to fix any AppVeyor build failures in the C# code.

@chwarr chwarr merged commit 3454728 into microsoft:master May 18, 2020
@chwarr chwarr deleted the grpc-unnamed-typedef branch July 6, 2020 22:20
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 this pull request may close these issues.

Bond build failed with error C5208 in MSVC
2 participants