Skip to content

Commit

Permalink
Give up on compiling exo_planet_c_api.cpp with MSVC /EHs-c-:
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
rwgk committed Sep 16, 2024
1 parent d1527e3 commit 6cb1d65
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -493,9 +493,7 @@ foreach(target ${test_targets})
endif()

if("${target}" STREQUAL "exo_planet_c_api")
if(MSVC)
target_compile_options(${target} PRIVATE /EHs-c-)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Intel|Clang|NVHPC)")
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Intel|Clang|NVHPC)")
target_compile_options(${target} PRIVATE -fno-exceptions)
endif()
endif()
Expand Down
4 changes: 2 additions & 2 deletions tests/exo_planet_c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// In production situations it is totally fine to build with
// C++ Exception Handling enabled. However, here we want to ensure that
// C++ Exception Handling is not required.
#ifdef __EMSCRIPTEN__
// Too much trouble making the required cmake changes.
#if defined(_MSC_VER) || defined(__EMSCRIPTEN__)
// Too much trouble making the required cmake changes (see PR #5375).
#else
# ifdef __cpp_exceptions
// https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations#__cpp_exceptions
Expand Down

0 comments on commit 6cb1d65

Please sign in to comment.