-
Notifications
You must be signed in to change notification settings - Fork 35
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
Make version with no exception support #27
Comments
Note to self: deferred in Allow use with exceptions disabled, plan 11, nonstd-lite project issue 4. |
Note to self: Ask Martin to have the whole |
Because of nonstd::optional_lite also has an issues with compilation without exceptions enabled. |
In version 0.4.0. |
Thanks for 0.4.0 ... Basically this is not how MS STL switches to no C++ exceptions builds. // expected.hpp #55
// Control presence of exception handling (try and auto discover):
#ifndef nsel_CONFIG_NO_EXCEPTIONS
# if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)
# define nsel_CONFIG_NO_EXCEPTIONS 0
# else
# define nsel_CONFIG_NO_EXCEPTIONS 1
# endif
#endif MS STL does not use // Control presence of exception handling (try and auto discover):
// Now nonstd and MS STL both depend on the same symbol
#ifndef nsel_CONFIG_NO_EXCEPTIONS
# if defined(__cpp_exceptions) || defined(__EXCEPTIONS) || (_HAS_EXCEPTIONS == 1 )
# define nsel_CONFIG_NO_EXCEPTIONS 0
# else
# define nsel_CONFIG_NO_EXCEPTIONS 1
# endif
#endif
HTH |
@DBJDBJ Thanks for your input. Wondering if the line should also contain
Edit: Apparently easy to forget, according to Preprocessing directives, 15.2 Conditional inclusion the following is fine:
|
@martinmoene yes that is right, thanks ... I think in the WIN32 world // Depending on _HAS_EXCEPTIONS
// MS STL transforms to using SEH instead of c++ exceptions
// <vcruntime.h> #100
#ifndef _HAS_EXCEPTIONS
#ifdef _KERNEL_MODE
#define _HAS_EXCEPTIONS 0
#else
#define _HAS_EXCEPTIONS 1
#endif // _KERNEL_MODE
#endif // _HAS_EXCEPTIONS
// _CPPUNWIND not mentioned Building #include <windows.h> // must include for SEH to work
#ifndef WIN32
#error this is Windows build only
#endif // WIN32
#if _HAS_EXCEPTIONS
#error _HAS_EXCEPTIONS must not be 1 , add the /kernel switch to the cl command line
#endif
#include <vector>
#include <stdio.h>
// also would like to use
// full nonstd in here
// #include <nonstd/whatever>
/*
Caveat Emptor: how to build with /kernel switch
it is not enough to just provide /kernel switch
one has to manually remove any /EH switch
usually in windows builds /EHsc is added by default
This will not stop the build but RTTI (/GR-) has to be
also explicitly added as it is not switched off
by using the /kernel switch
*/
static void does_not_compile(void)
{
/*
error C2980: C++ exception handling is not supported with /kernel
try { throw 13; }
catch (...) {}
*/
}
int main()
{
__try {
// also would like to use
// full nonstd in here
std::vector<int> v_{ 1,2,3 };
// std::out_of_range
(void)v_.at(42);
}
__except ( EXCEPTION_EXECUTE_HANDLER /* aka 0*/) {
puts("Structured Exception from MS STL was caught");
}
return 42;
} Kind regards ... |
https://github.com/dbj-data/dbj-bench/blob/master/r_and_d/ms_stl_seh.md A bit more presentable |
I am slightly worried if I was clear enough, but it is not my fault: one, two or three symbols are made to dance to achieve one "thing".
Thus it is a "good thing" HTH |
For some special cases (and reasons) it would be perfect to have version of the nonstd::expected implementation with no exception support (like @TartanLlama version).
The text was updated successfully, but these errors were encountered: