Skip to content

Commit 6cb1d65

Browse files
committed
Give up on compiling exo_planet_c_api.cpp with MSVC /EHs-c-:
There was one trouble maker (all other jobs worked): Visual Studio 15 2017: ``` cl : Command line warning D9025: overriding '/EHc' with '/EHc-' [C:\projects\pybind11\tests\exo_planet_c_api.vcxproj] ... C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\xlocale(319): error C2220: warning treated as error - no 'object' file generated [C:\projects\pybind11\tests\exo_planet_c_api.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\xlocale(319): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc ```
1 parent d1527e3 commit 6cb1d65

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

tests/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,7 @@ foreach(target ${test_targets})
493493
endif()
494494

495495
if("${target}" STREQUAL "exo_planet_c_api")
496-
if(MSVC)
497-
target_compile_options(${target} PRIVATE /EHs-c-)
498-
elseif(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Intel|Clang|NVHPC)")
496+
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Intel|Clang|NVHPC)")
499497
target_compile_options(${target} PRIVATE -fno-exceptions)
500498
endif()
501499
endif()

tests/exo_planet_c_api.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// In production situations it is totally fine to build with
44
// C++ Exception Handling enabled. However, here we want to ensure that
55
// C++ Exception Handling is not required.
6-
#ifdef __EMSCRIPTEN__
7-
// Too much trouble making the required cmake changes.
6+
#if defined(_MSC_VER) || defined(__EMSCRIPTEN__)
7+
// Too much trouble making the required cmake changes (see PR #5375).
88
#else
99
# ifdef __cpp_exceptions
1010
// https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations#__cpp_exceptions

0 commit comments

Comments
 (0)