-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Fix compiler detection with clang-cl #5816
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
Conversation
rwgk
left a comment
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.
From the PR description:
but that macro is defined to nothing
Is that correct? I'm thinking it must be using the MSVC definitions? Could you please review the PR description for correctness and also make the suggested changelog more specific (mention warning suppression pragmas)?
| // only use compiler specifics if you need to check specific versions, e.g. Apple Clang vs. vanilla | ||
| // Clang. | ||
| #if defined(_MSC_VER) | ||
| #if defined(_MSC_VER) && !defined(__clang__) // clang-cl also defines _MSC_VER |
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.
Could you please try to move this block last (below __GNUC__), with a small but carefully written comment to explain why it should stay there? (Your favorite LLM can probably help doing this quickly.)
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.
Good idea, done.
Yes, the definition is #ifdef PYBIND11_COMPILER_CLANG
# define PYBIND11_WARNING_DISABLE_CLANG(name) PYBIND11_PRAGMA(clang diagnostic ignored name)
#else
# define PYBIND11_WARNING_DISABLE_CLANG(name)
#endifI updated the PR description to include more details. |
|
Thanks! |
Description
I am getting compiler warnings using clang-cl on Windows. These warnings are suppressed in pybind11 using
PYBIND11_WARNING_DISABLE_CLANGwhich is defined asHowever, for clang-cl,
PYBIND11_COMPILER_CLANGis undefined because clang-cl also defines_MSC_VERand thus the compiler is detected as msvc.Suggested changelog entry:
pybind11/detail/pybind11_namespace_macros.hfor clang-cl on Windows, to fix warning suppression macros.