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

PROTOBUF_MAYBE_CONSTEXPR should not be constexpr on MinGW #8049

Closed
brechtsanders opened this issue Nov 14, 2020 · 6 comments
Closed

PROTOBUF_MAYBE_CONSTEXPR should not be constexpr on MinGW #8049

brechtsanders opened this issue Nov 14, 2020 · 6 comments

Comments

@brechtsanders
Copy link
Contributor

I tried to compile protobuf 3.14.0 for Windows with MinGW-w64 and got this compiler error:

src/google/protobuf/map_field.h:336:37: error: call to non-'constexpr' function 'google::protobuf::internal::WrappedMutex::WrappedMutex()'

It appears this is documented and fixed as an MSVC issue, but it seems to be a general Windows issue.
So after making the following change compilation was succesful:

patch -ulbf src/google/protobuf/port_def.inc << EOF
@@ -560,10 +560,10 @@
 #define PROTOBUF_CONSTINIT
 #endif

-// Some constructors can't be constexpr under MSVC, but given that MSVC will not
+// Some constructors can't be constexpr under Windows, but given that Windows will not
 // do constant initialization of globals anyway we can omit `constexpr` from
 // them. These constructors are marked with PROTOBUF_MAYBE_CONSTEXPR
-#if defined(_MSC_VER)
+#if defined(_WIN32)
 #define PROTOBUF_MAYBE_CONSTEXPR
 #else
 #define PROTOBUF_MAYBE_CONSTEXPR constexpr
EOF
@acozzette
Copy link
Member

@brechtsanders Thanks for reporting this, would you be interested in sending a pull request with that fix?

@jayconrod
Copy link

Any chance this could be fixed in the near future? This blocks Bazel+Go users from using protos on Windows. Go is only compatible with gcc and clang (not MSVC), so users generally need to use mingw64, which means they also use it to build protoc.

@ah-edg
Copy link

ah-edg commented Feb 11, 2021

@acozzette as @brechtsanders does not seem to want to send a PR, is there anything blocking someone else to send this very small change? I think this is a copyright/legal issue, but can't quite imagine this would pose a legal problem due to its size.
Is there any other reason?

@brechtsanders
Copy link
Contributor Author

It's not that I dont want to make a pull request. Code changed substantially and I don't see where the fix for this issue should go in the changed code.

@brechtsanders
Copy link
Contributor Author

Ok, I had a look at the latest code and created a pull request (#8286)

@brechtsanders
Copy link
Contributor Author

brechtsanders commented Feb 11, 2021

Pull request is missing a label because it doesn't know the .inc file I changed is C source code.
I don't seem to be able to add the C language label, so the PR will need attention from somebody who can label it as a C change.

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

No branches or pull requests

4 participants