-
Notifications
You must be signed in to change notification settings - Fork 325
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
Bond build failed with error C5208 in MSVC #1027
Comments
Hi chwarr, The code in that change is no longer considered well-formed code. A unnamed class with typedef name for linkage purposes is not allowed to have certain properties, see There are a couple of ways you can go about changing the code with the most obvious fix being apply a name to these types. In fact, a name would further shorten the typenames in the PDB because the entry for the unnamed typedef symbol will be prefixed with extra information which forces it to be unique. Another, arguably easier, solution is to remove the Let me know if you have any further questions about this! Cameron DaCamara, Visual C++ Compiler Team. |
FYI, @Cheney-W and @cdacamar: we believe that this has been fixed in master as of commit f1cb707134. Thanks to @BertusGreeff for contributing the fix, and thank you both for the report and your help crafting the fix! |
@chwarr and @BertusGreeff, thanks for fixing this issue! The MSVC team testing the latest source code under /std:c++latest mode, other auto-generated files still triggered this issue, see the build.log for details, could you help fix this issue? error: |
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
I think I have a fix for this problem in the generated _grpc.h code. PR #1041. |
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
@215020267, I think I've fixed this in the _grpc.h headers in commit 3454728 that I just merged into master. |
Any plans for a maintenance release containing these changes? |
I'm also running into the same problem. |
@mdslack & @jthelin: the 9.0.0 release is live now. NuGet.org has the packages too. |
Hello, I'm a member of Microsoft VCPKG, when I built this port in an internal version of Visual Studio, it failed with following errors:
cpp\generated\bond\core\bond_reflection.h(36): error C5208: unnamed class used in typedef name cannot declare members other than non-static data members, member enumerations, or member classes
This error is caused by our implementation of [C ++ 20] Implement P1766R1, this change introduces a new warning/error when compiling code that looks like this:
In order to fix patterns like this the unnamed class must be given a name explicitly:
In the bond_reflection.h file, there are 30 structures like this that will trigger error C5208:
After testing, adding the name to the structure can fix this problem:
typedef struct **message_**: ::bond::reflection::FieldTemplate<
Since this file is an auto-generated file by the tool: Bond Compiler 0.11.0.3, and I'm not very clear about its generation rules, so could you please fix this problem? If you need any information, please contact me directly. Thanks in advance.
The text was updated successfully, but these errors were encountered: