-
-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Windows: Add missing extern "C" for hidsdi.h on MinGW < 12.0.0
#115010
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
Windows: Add missing extern "C" for hidsdi.h on MinGW < 12.0.0
#115010
Conversation
638c217 to
dac1721
Compare
| // Workaround missing `extern "C"` in MinGW-w64 < 12.0.0. | ||
| #if defined(__MINGW32__) && (!defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 12) | ||
| extern "C" { | ||
| #include <hidsdi.h> | ||
| } | ||
| #else | ||
| #include <hidsdi.h> | ||
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, both are a bit messy:
| // Workaround missing `extern "C"` in MinGW-w64 < 12.0.0. | |
| #if defined(__MINGW32__) && (!defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 12) | |
| extern "C" { | |
| #include <hidsdi.h> | |
| } | |
| #else | |
| #include <hidsdi.h> | |
| #endif | |
| // Workaround missing `extern "C"` in MinGW-w64 < 12.0.0. | |
| #if defined(__MINGW32__) && (!defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 12) | |
| extern "C" { | |
| #endif | |
| #include <hidsdi.h> | |
| #if defined(__MINGW32__) && (!defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 12) | |
| } | |
| #endif |
|
Yes it builds for me on Ubuntu 24.04 with this change. |
|
Cherry-picked for 4.5.2. (Ahead of the likely merge of this PR, as I want to include it in 4.5.2.rc1.) |
| #include <winternl.h> | ||
|
|
||
| // Workaround missing `extern "C"` in MinGW-w64 < 12.0.0. | ||
| #if defined(__MINGW32__) && (!defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 12) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nested extern "C"s should not do anything (at least when header has it in #ifdef __cplusplus, which newer MinGW does), so version check can be omitted, but I guess it's better to still have it to make it clear it is MinGW issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I mostly added it for documentation purposes, so we don't refactor this to remove the unnecessary check for modern compilers.
Follow-up to #113013.
Works for me on Fedora 40 with MinGW 11.0.1.
Does it work for you too on Ubuntu 24.04 @BuzzLord?