-
-
Notifications
You must be signed in to change notification settings - Fork 67
Use the '-Xclang -fexceptions -Xclang -fcxx-exceptions' flag set to enables C++ EH in clang-cl #90
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
Comments
Can you please share what version of MSVC and CMake you have, how do you invoke CMake and what version of MSVC does clang-cl identify as when you run As far as I can see, CMake should automatically enable exceptions. When I run CMake in Visual Studio, there's I'm not against adding those flags if it turns out they are really needed, but I want to make sure the issue is not specific to your setup/configuration and to understand why they are sometimes needed and sometimes not. |
I'm using the latest MSVC 2022 community edition with the latest clang-cl built from official git source, and qt-cmake.bat to generate Ninja project, got something like below:
clang-cl version:
cmake version:
|
Thanks a lot, that explains it - with this setup you end up targeting the |
MSVC requires that exceptions are explicitly enabled using the `\EH` flag, so clang-cl copies that behavior. When CMake targets the Windows-MSVC platform (that is when using "Visual Studio" generator), CMake takes care of adding `\EHsc` to `CXXFLAGS`. However when the clang-cl compiler is specified manually (`CMAKE_CXX_COMPILER`) and another generator, like Ninja is used, then CMake ends up targeting the Windows-Clang-CXX platform, which does not enable exceptions, so we have to do that ourselves. To keep the code simple, we do not try to detect the target platform or such, we simply append the `\EHsc` flag when we detect clang-cl.
Could you please try #91 and confirm it fixes the problem? |
Great! It works. |
Explicitly enable exception support for clang-cl (fixes #90)
With the latest clang-cl, it reports errors like below:
If C++ EH is enabled, errors disappeared.
The text was updated successfully, but these errors were encountered: