Fix compiler detection with clang-cl#5816
Conversation
rwgk
left a comment
There was a problem hiding this comment.
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.
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.
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.