From 65765885eb191608c17b1dd263e3ab0d10aa3651 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Tue, 27 Jul 2021 17:44:14 -0700 Subject: [PATCH 1/8] Removing pragma for 4100 (to see what is still broken with the latest code). --- include/pybind11/pybind11.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index b14aff58a2..abf8bf3d4c 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -12,7 +12,6 @@ #if defined(_MSC_VER) && !defined(__INTEL_COMPILER) # pragma warning(push) -# pragma warning(disable: 4100) // warning C4100: Unreferenced formal parameter # pragma warning(disable: 4127) // warning C4127: Conditional expression is constant # pragma warning(disable: 4505) // warning C4505: 'PySlice_GetIndicesEx': unreferenced local function has been removed (PyPy only) #elif defined(__GNUG__) && !defined(__clang__) && !defined(__INTEL_COMPILER) From a7a39dd3d2fd3c98e3d8b6c9d0f2ff97262ed6d4 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Tue, 27 Jul 2021 17:49:29 -0700 Subject: [PATCH 2/8] Adding --keep-going --- .github/workflows/ci.yml | 60 ++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 03c9225c12..0e8e0ea676 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -106,7 +106,7 @@ jobs: ${{ matrix.args }} - name: Build C++11 - run: cmake --build . -j 2 + run: cmake --build . -j 2 -- --keep-going - name: Python tests C++11 run: cmake --build . --target pytest -j 2 @@ -114,10 +114,10 @@ jobs: - name: C++11 tests # TODO: Figure out how to load the DLL on Python 3.8+ if: "!(runner.os == 'Windows' && (matrix.python == 3.8 || matrix.python == 3.9 || matrix.python == '3.10-dev'))" - run: cmake --build . --target cpptest -j 2 + run: cmake --build . --target cpptest -j 2 -- --keep-going - name: Interface test C++11 - run: cmake --build . --target test_cmake_build + run: cmake --build . --target test_cmake_build -- --keep-going - name: Clean directory run: git clean -fdx @@ -134,7 +134,7 @@ jobs: ${{ matrix.args2 }} - name: Build - run: cmake --build build2 -j 2 + run: cmake --build build2 -j 2 -- --keep-going - name: Python tests run: cmake --build build2 --target pytest @@ -142,10 +142,10 @@ jobs: - name: C++ tests # TODO: Figure out how to load the DLL on Python 3.8+ if: "!(runner.os == 'Windows' && (matrix.python == 3.8 || matrix.python == 3.9 || matrix.python == '3.10-dev'))" - run: cmake --build build2 --target cpptest + run: cmake --build build2 --target cpptest -- --keep-going - name: Interface test - run: cmake --build build2 --target test_cmake_build + run: cmake --build build2 --target test_cmake_build -- --keep-going # Eventually Microsoft might have an action for setting up # MSVC, but for now, this action works: @@ -234,13 +234,13 @@ jobs: -DCMAKE_CXX_STANDARD=17 - name: Build - run: cmake --build build -j 2 + run: cmake --build build -j 2 -- --keep-going - name: Python tests run: cmake --build build --target pytest - name: C++ tests - run: cmake --build build --target cpptest + run: cmake --build build --target cpptest -- --keep-going - name: Run Valgrind on Python tests if: matrix.valgrind @@ -289,16 +289,16 @@ jobs: -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") - name: Build - run: cmake --build build -j 2 + run: cmake --build build -j 2 -- --keep-going - name: Python tests run: cmake --build build --target pytest - name: C++ tests - run: cmake --build build --target cpptest + run: cmake --build build --target cpptest -- --keep-going - name: Interface test - run: cmake --build build --target test_cmake_build + run: cmake --build build --target test_cmake_build -- --keep-going # Testing NVCC; forces sources to behave like .cu files @@ -318,7 +318,7 @@ jobs: run: cmake -S . -B build -DPYBIND11_CUDA_TESTS=ON -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON - name: Build - run: cmake --build build -j2 --verbose + run: cmake --build build -j2 --verbose -- --keep-going - name: Python tests run: cmake --build build --target pytest @@ -400,7 +400,7 @@ jobs: # Building before installing Pip should produce a warning but not an error - name: Build - run: cmake3 --build build -j 2 --verbose + run: cmake3 --build build -j 2 --verbose -- --keep-going - name: Install CMake with pip run: | @@ -411,10 +411,10 @@ jobs: run: cmake3 --build build --target pytest - name: C++ tests - run: cmake3 --build build --target cpptest + run: cmake3 --build build --target cpptest -- --keep-going - name: Interface test - run: cmake3 --build build --target test_cmake_build + run: cmake3 --build build --target test_cmake_build -- --keep-going # Testing on GCC using the GCC docker images (only recent images supported) @@ -457,16 +457,16 @@ jobs: -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") - name: Build - run: cmake --build build -j 2 + run: cmake --build build -j 2 -- --keep-going - name: Python tests run: cmake --build build --target pytest - name: C++ tests - run: cmake --build build --target cpptest + run: cmake --build build --target cpptest -- --keep-going - name: Interface test - run: cmake --build build --target test_cmake_build + run: cmake --build build --target test_cmake_build -- --keep-going # Testing on ICC using the oneAPI apt repo @@ -515,7 +515,7 @@ jobs: - name: Build C++11 run: | set +e; source /opt/intel/oneapi/setvars.sh; set -e - cmake --build build-11 -j 2 -v + cmake --build build-11 -j 2 -v -- --keep-going - name: Python tests C++11 run: | @@ -526,12 +526,12 @@ jobs: - name: C++ tests C++11 run: | set +e; source /opt/intel/oneapi/setvars.sh; set -e - cmake --build build-11 --target cpptest + cmake --build build-11 --target cpptest -- --keep-going - name: Interface test C++11 run: | set +e; source /opt/intel/oneapi/setvars.sh; set -e - cmake --build build-11 --target test_cmake_build + cmake --build build-11 --target test_cmake_build -- --keep-going - name: Configure C++17 run: | @@ -547,7 +547,7 @@ jobs: - name: Build C++17 run: | set +e; source /opt/intel/oneapi/setvars.sh; set -e - cmake --build build-17 -j 2 -v + cmake --build build-17 -j 2 -v -- --keep-going - name: Python tests C++17 run: | @@ -558,12 +558,12 @@ jobs: - name: C++ tests C++17 run: | set +e; source /opt/intel/oneapi/setvars.sh; set -e - cmake --build build-17 --target cpptest + cmake --build build-17 --target cpptest -- --keep-going - name: Interface test C++17 run: | set +e; source /opt/intel/oneapi/setvars.sh; set -e - cmake --build build-17 --target test_cmake_build + cmake --build build-17 --target test_cmake_build -- --keep-going # Testing on CentOS (manylinux uses a centos base, and this is an easy way @@ -614,16 +614,16 @@ jobs: -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") - name: Build - run: cmake --build build -j 2 + run: cmake --build build -j 2 -- --keep-going - name: Python tests run: cmake --build build --target pytest - name: C++ tests - run: cmake --build build --target cpptest + run: cmake --build build --target cpptest -- --keep-going - name: Interface test - run: cmake --build build --target test_cmake_build + run: cmake --build build --target test_cmake_build -- --keep-going # This tests an "install" with the CMake tools @@ -758,7 +758,7 @@ jobs: -DDOWNLOAD_EIGEN=ON ${{ matrix.args }} - name: Build C++11 - run: cmake --build build -j 2 + run: cmake --build build -j 2 -- --keep-going - name: Run tests run: cmake --build build -t pytest @@ -804,7 +804,7 @@ jobs: -DDOWNLOAD_EIGEN=ON - name: Build C++14 - run: cmake --build build -j 2 + run: cmake --build build -j 2 -- --keep-going - name: Run all checks run: cmake --build build -t check @@ -855,7 +855,7 @@ jobs: ${{ matrix.args }} - name: Build ${{ matrix.std }} - run: cmake --build build -j 2 + run: cmake --build build -j 2 -- --keep-going - name: Run all checks run: cmake --build build -t check From 205e511c13270bb918bdc4908e6c1de9190cc053 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Tue, 27 Jul 2021 22:04:08 -0700 Subject: [PATCH 3/8] Revert "Adding --keep-going" This reverts commit 1c844c6ffd07a6111b644811e7e3b0a50b9d44bb. --- .github/workflows/ci.yml | 60 ++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e8e0ea676..03c9225c12 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -106,7 +106,7 @@ jobs: ${{ matrix.args }} - name: Build C++11 - run: cmake --build . -j 2 -- --keep-going + run: cmake --build . -j 2 - name: Python tests C++11 run: cmake --build . --target pytest -j 2 @@ -114,10 +114,10 @@ jobs: - name: C++11 tests # TODO: Figure out how to load the DLL on Python 3.8+ if: "!(runner.os == 'Windows' && (matrix.python == 3.8 || matrix.python == 3.9 || matrix.python == '3.10-dev'))" - run: cmake --build . --target cpptest -j 2 -- --keep-going + run: cmake --build . --target cpptest -j 2 - name: Interface test C++11 - run: cmake --build . --target test_cmake_build -- --keep-going + run: cmake --build . --target test_cmake_build - name: Clean directory run: git clean -fdx @@ -134,7 +134,7 @@ jobs: ${{ matrix.args2 }} - name: Build - run: cmake --build build2 -j 2 -- --keep-going + run: cmake --build build2 -j 2 - name: Python tests run: cmake --build build2 --target pytest @@ -142,10 +142,10 @@ jobs: - name: C++ tests # TODO: Figure out how to load the DLL on Python 3.8+ if: "!(runner.os == 'Windows' && (matrix.python == 3.8 || matrix.python == 3.9 || matrix.python == '3.10-dev'))" - run: cmake --build build2 --target cpptest -- --keep-going + run: cmake --build build2 --target cpptest - name: Interface test - run: cmake --build build2 --target test_cmake_build -- --keep-going + run: cmake --build build2 --target test_cmake_build # Eventually Microsoft might have an action for setting up # MSVC, but for now, this action works: @@ -234,13 +234,13 @@ jobs: -DCMAKE_CXX_STANDARD=17 - name: Build - run: cmake --build build -j 2 -- --keep-going + run: cmake --build build -j 2 - name: Python tests run: cmake --build build --target pytest - name: C++ tests - run: cmake --build build --target cpptest -- --keep-going + run: cmake --build build --target cpptest - name: Run Valgrind on Python tests if: matrix.valgrind @@ -289,16 +289,16 @@ jobs: -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") - name: Build - run: cmake --build build -j 2 -- --keep-going + run: cmake --build build -j 2 - name: Python tests run: cmake --build build --target pytest - name: C++ tests - run: cmake --build build --target cpptest -- --keep-going + run: cmake --build build --target cpptest - name: Interface test - run: cmake --build build --target test_cmake_build -- --keep-going + run: cmake --build build --target test_cmake_build # Testing NVCC; forces sources to behave like .cu files @@ -318,7 +318,7 @@ jobs: run: cmake -S . -B build -DPYBIND11_CUDA_TESTS=ON -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON - name: Build - run: cmake --build build -j2 --verbose -- --keep-going + run: cmake --build build -j2 --verbose - name: Python tests run: cmake --build build --target pytest @@ -400,7 +400,7 @@ jobs: # Building before installing Pip should produce a warning but not an error - name: Build - run: cmake3 --build build -j 2 --verbose -- --keep-going + run: cmake3 --build build -j 2 --verbose - name: Install CMake with pip run: | @@ -411,10 +411,10 @@ jobs: run: cmake3 --build build --target pytest - name: C++ tests - run: cmake3 --build build --target cpptest -- --keep-going + run: cmake3 --build build --target cpptest - name: Interface test - run: cmake3 --build build --target test_cmake_build -- --keep-going + run: cmake3 --build build --target test_cmake_build # Testing on GCC using the GCC docker images (only recent images supported) @@ -457,16 +457,16 @@ jobs: -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") - name: Build - run: cmake --build build -j 2 -- --keep-going + run: cmake --build build -j 2 - name: Python tests run: cmake --build build --target pytest - name: C++ tests - run: cmake --build build --target cpptest -- --keep-going + run: cmake --build build --target cpptest - name: Interface test - run: cmake --build build --target test_cmake_build -- --keep-going + run: cmake --build build --target test_cmake_build # Testing on ICC using the oneAPI apt repo @@ -515,7 +515,7 @@ jobs: - name: Build C++11 run: | set +e; source /opt/intel/oneapi/setvars.sh; set -e - cmake --build build-11 -j 2 -v -- --keep-going + cmake --build build-11 -j 2 -v - name: Python tests C++11 run: | @@ -526,12 +526,12 @@ jobs: - name: C++ tests C++11 run: | set +e; source /opt/intel/oneapi/setvars.sh; set -e - cmake --build build-11 --target cpptest -- --keep-going + cmake --build build-11 --target cpptest - name: Interface test C++11 run: | set +e; source /opt/intel/oneapi/setvars.sh; set -e - cmake --build build-11 --target test_cmake_build -- --keep-going + cmake --build build-11 --target test_cmake_build - name: Configure C++17 run: | @@ -547,7 +547,7 @@ jobs: - name: Build C++17 run: | set +e; source /opt/intel/oneapi/setvars.sh; set -e - cmake --build build-17 -j 2 -v -- --keep-going + cmake --build build-17 -j 2 -v - name: Python tests C++17 run: | @@ -558,12 +558,12 @@ jobs: - name: C++ tests C++17 run: | set +e; source /opt/intel/oneapi/setvars.sh; set -e - cmake --build build-17 --target cpptest -- --keep-going + cmake --build build-17 --target cpptest - name: Interface test C++17 run: | set +e; source /opt/intel/oneapi/setvars.sh; set -e - cmake --build build-17 --target test_cmake_build -- --keep-going + cmake --build build-17 --target test_cmake_build # Testing on CentOS (manylinux uses a centos base, and this is an easy way @@ -614,16 +614,16 @@ jobs: -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") - name: Build - run: cmake --build build -j 2 -- --keep-going + run: cmake --build build -j 2 - name: Python tests run: cmake --build build --target pytest - name: C++ tests - run: cmake --build build --target cpptest -- --keep-going + run: cmake --build build --target cpptest - name: Interface test - run: cmake --build build --target test_cmake_build -- --keep-going + run: cmake --build build --target test_cmake_build # This tests an "install" with the CMake tools @@ -758,7 +758,7 @@ jobs: -DDOWNLOAD_EIGEN=ON ${{ matrix.args }} - name: Build C++11 - run: cmake --build build -j 2 -- --keep-going + run: cmake --build build -j 2 - name: Run tests run: cmake --build build -t pytest @@ -804,7 +804,7 @@ jobs: -DDOWNLOAD_EIGEN=ON - name: Build C++14 - run: cmake --build build -j 2 -- --keep-going + run: cmake --build build -j 2 - name: Run all checks run: cmake --build build -t check @@ -855,7 +855,7 @@ jobs: ${{ matrix.args }} - name: Build ${{ matrix.std }} - run: cmake --build build -j 2 -- --keep-going + run: cmake --build build -j 2 - name: Run all checks run: cmake --build build -t check From e8e52a46dcc59cfaec477b3524334a683c1b492e Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Wed, 28 Jul 2021 08:14:08 -0700 Subject: [PATCH 4/8] Introducing PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100. --- include/pybind11/attr.h | 5 +++++ include/pybind11/cast.h | 1 + include/pybind11/detail/common.h | 7 +++++++ include/pybind11/detail/descr.h | 1 + include/pybind11/detail/init.h | 3 +++ include/pybind11/detail/type_caster_base.h | 2 ++ include/pybind11/pybind11.h | 2 ++ 7 files changed, 21 insertions(+) diff --git a/include/pybind11/attr.h b/include/pybind11/attr.h index 60ed9fd90e..20d119f0ff 100644 --- a/include/pybind11/attr.h +++ b/include/pybind11/attr.h @@ -516,18 +516,22 @@ template struct process_attribute struct process_attributes { static void init(const Args&... args, function_record *r) { + PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(r); int unused[] = { 0, (process_attribute::type>::init(args, r), 0) ... }; ignore_unused(unused); } static void init(const Args&... args, type_record *r) { + PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(r); int unused[] = { 0, (process_attribute::type>::init(args, r), 0) ... }; ignore_unused(unused); } static void precall(function_call &call) { + PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(call); int unused[] = { 0, (process_attribute::type>::precall(call), 0) ... }; ignore_unused(unused); } static void postcall(function_call &call, handle fn_ret) { + PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(call, fn_ret); int unused[] = { 0, (process_attribute::type>::postcall(call, fn_ret), 0) ... }; ignore_unused(unused); } @@ -545,6 +549,7 @@ template ::value...), size_t self = constexpr_sum(std::is_same::value...)> constexpr bool expected_num_args(size_t nargs, bool has_args, bool has_kwargs) { + PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(nargs, has_args, has_kwargs); return named == 0 || (self + named + size_t(has_args) + size_t(has_kwargs)) == nargs; } diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 898047b304..5ff0355a6f 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -605,6 +605,7 @@ template class Tuple, typename... Ts> class tuple_caster /* Implementation: Convert a C++ tuple into a Python tuple */ template static handle cast_impl(T &&src, return_value_policy policy, handle parent, index_sequence) { + PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(src, policy, parent); std::array entries{{ reinterpret_steal(make_caster::cast(std::get(std::forward(src)), policy, parent))... }}; diff --git a/include/pybind11/detail/common.h b/include/pybind11/detail/common.h index 0b4e30c18b..5538ed6910 100644 --- a/include/pybind11/detail/common.h +++ b/include/pybind11/detail/common.h @@ -913,5 +913,12 @@ inline static std::shared_ptr try_get_shared_from_this(std::enable_shared_fro #endif } +#if defined(_MSC_VER) +inline constexpr void workaround_incorrect_msvc_c4100(...) {} +#define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...) detail::workaround_incorrect_msvc_c4100(__VA_ARGS__) +#else +#define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...) +#endif + PYBIND11_NAMESPACE_END(detail) PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE) diff --git a/include/pybind11/detail/descr.h b/include/pybind11/detail/descr.h index 7cb8350e7b..0acfc7db37 100644 --- a/include/pybind11/detail/descr.h +++ b/include/pybind11/detail/descr.h @@ -42,6 +42,7 @@ struct descr { template constexpr descr plus_impl(const descr &a, const descr &b, index_sequence, index_sequence) { + PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(b); return {a.text[Is1]..., b.text[Is2]...}; } diff --git a/include/pybind11/detail/init.h b/include/pybind11/detail/init.h index 3269e04254..3ebec041f0 100644 --- a/include/pybind11/detail/init.h +++ b/include/pybind11/detail/init.h @@ -94,6 +94,7 @@ void construct(...) { // construct an Alias from the returned base instance. template void construct(value_and_holder &v_h, Cpp *ptr, bool need_alias) { + PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(need_alias); no_nullptr(ptr); if (Class::has_alias && need_alias && !is_alias(ptr)) { // We're going to try to construct an alias by moving the cpp type. Whether or not @@ -131,6 +132,7 @@ void construct(value_and_holder &v_h, Alias *alias_ptr, bool) { // derived type (through those holder's implicit conversion from derived class holder constructors). template void construct(value_and_holder &v_h, Holder holder, bool need_alias) { + PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(need_alias); auto *ptr = holder_helper>::get(holder); no_nullptr(ptr); // If we need an alias, check that the held pointer is actually an alias instance @@ -148,6 +150,7 @@ void construct(value_and_holder &v_h, Holder holder, bool need_alias) { // need it, we simply move-construct the cpp value into a new instance. template void construct(value_and_holder &v_h, Cpp &&result, bool need_alias) { + PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(need_alias); static_assert(std::is_move_constructible>::value, "pybind11::init() return-by-value factory function requires a movable class"); if (Class::has_alias && need_alias) diff --git a/include/pybind11/detail/type_caster_base.h b/include/pybind11/detail/type_caster_base.h index 2a675418a7..e2d1bcb8cc 100644 --- a/include/pybind11/detail/type_caster_base.h +++ b/include/pybind11/detail/type_caster_base.h @@ -930,6 +930,7 @@ template class type_caster_base : public type_caster_generic { does not have a private operator new implementation. */ template ::value>> static auto make_copy_constructor(const T *x) -> decltype(new T(*x), Constructor{}) { + PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(x); return [](const void *arg) -> void * { return new T(*reinterpret_cast(arg)); }; @@ -937,6 +938,7 @@ template class type_caster_base : public type_caster_generic { template ::value>> static auto make_move_constructor(const T *x) -> decltype(new T(std::move(*const_cast(x))), Constructor{}) { + PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(x); return [](const void *arg) -> void * { return new T(std::move(*const_cast(reinterpret_cast(arg)))); }; diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index abf8bf3d4c..139a4111e9 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -1387,12 +1387,14 @@ class class_ : public detail::generic_type { template class_ &def(const detail::initimpl::constructor &init, const Extra&... extra) { + PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(init); init.execute(*this, extra...); return *this; } template class_ &def(const detail::initimpl::alias_constructor &init, const Extra&... extra) { + PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(init); init.execute(*this, extra...); return *this; } From 85dd61c52e6c8f431d0db84df1716cf3b427b609 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Wed, 28 Jul 2021 08:51:49 -0700 Subject: [PATCH 5/8] _MSC_VER <= 1916 --- include/pybind11/detail/common.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/pybind11/detail/common.h b/include/pybind11/detail/common.h index 5538ed6910..88392f6ff4 100644 --- a/include/pybind11/detail/common.h +++ b/include/pybind11/detail/common.h @@ -913,11 +913,12 @@ inline static std::shared_ptr try_get_shared_from_this(std::enable_shared_fro #endif } -#if defined(_MSC_VER) +#if defined(_MSC_VER) && _MSC_VER <= 1916 inline constexpr void workaround_incorrect_msvc_c4100(...) {} -#define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...) detail::workaround_incorrect_msvc_c4100(__VA_ARGS__) +# define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...) \ + detail::workaround_incorrect_msvc_c4100(__VA_ARGS__) #else -#define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...) +# define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...) #endif PYBIND11_NAMESPACE_END(detail) From 42a2c021e2dab2d62abf9d7158d17196d07d42b3 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Wed, 28 Jul 2021 10:42:48 -0700 Subject: [PATCH 6/8] Replacing simple variadic function with variadic template (attempt to resolve MSVC 2017 failures). --- include/pybind11/detail/common.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/pybind11/detail/common.h b/include/pybind11/detail/common.h index 88392f6ff4..8c15919fa6 100644 --- a/include/pybind11/detail/common.h +++ b/include/pybind11/detail/common.h @@ -914,7 +914,8 @@ inline static std::shared_ptr try_get_shared_from_this(std::enable_shared_fro } #if defined(_MSC_VER) && _MSC_VER <= 1916 -inline constexpr void workaround_incorrect_msvc_c4100(...) {} +template +inline constexpr void workaround_incorrect_msvc_c4100(Args &&...) {} # define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...) \ detail::workaround_incorrect_msvc_c4100(__VA_ARGS__) #else From 74968e1bab8a740b476b45fd4a31cdd06c819c05 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Wed, 28 Jul 2021 10:56:35 -0700 Subject: [PATCH 7/8] Preserving existing comment (moved from pybind11.h to detail/common.h). --- include/pybind11/detail/common.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/pybind11/detail/common.h b/include/pybind11/detail/common.h index 8c15919fa6..6e78162219 100644 --- a/include/pybind11/detail/common.h +++ b/include/pybind11/detail/common.h @@ -914,6 +914,7 @@ inline static std::shared_ptr try_get_shared_from_this(std::enable_shared_fro } #if defined(_MSC_VER) && _MSC_VER <= 1916 +// warning C4100: Unreferenced formal parameter template inline constexpr void workaround_incorrect_msvc_c4100(Args &&...) {} # define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...) \ From c0e6fad6cb5298e16b5641b4d3413a7f75bbd810 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Wed, 28 Jul 2021 13:54:31 -0700 Subject: [PATCH 8/8] Adding blank lines for readability. --- include/pybind11/detail/common.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/pybind11/detail/common.h b/include/pybind11/detail/common.h index 6e78162219..0add6272f5 100644 --- a/include/pybind11/detail/common.h +++ b/include/pybind11/detail/common.h @@ -914,11 +914,14 @@ inline static std::shared_ptr try_get_shared_from_this(std::enable_shared_fro } #if defined(_MSC_VER) && _MSC_VER <= 1916 + // warning C4100: Unreferenced formal parameter template inline constexpr void workaround_incorrect_msvc_c4100(Args &&...) {} + # define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...) \ detail::workaround_incorrect_msvc_c4100(__VA_ARGS__) + #else # define PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(...) #endif