以编程方式确定是否启用异常 [英] Programmatically determine whether exceptions are enabled
本文介绍了以编程方式确定是否启用异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
由于 2014年的WG21 ,有一个推荐的宏使用
__ cpp_exceptions
如果支持异常,它将具有值为199711的值编译器符合C ++ 98。其他类似功能宏在此显示。
Most C++ compilers allow for exceptions to be disabled. Is there a way to determine it from the code without using compiler-specific preprocessor macros, such as _CPPUNWIND for MSVC? Ideally at compile time.
解决方案
Since WG21 in 2014, there is a recommended macro to use
__cpp_exceptions
It will have the value 199711 if exceptions are supported and the compiler conforms to C++98. Other similar feature macros are shown here.
这篇关于以编程方式确定是否启用异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文