本文介绍了c ++ 1z动态异常规范错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用新的GCC版本7.2.1编译我的项目,并且在动态异常规范方面存在问题:

I am trying to compile my project with new GCC version 7.2.1 and have a problem with dynamic exception specifications:

error: ISO C++1z does not allow dynamic exception specifications
  MEMORY_ALLOC_OPERATORS(SQLException)

问题是这些错误来自我无法控制的第三方库.

The problem is that these errors come from third-party libraries which I do not control.

有什么办法可以解决?据我所知,我不能告诉编译器用警告代替错误.不能使用--std=c++14,因为我想使用C ++ 1z的新功能.

Is there a some way to fix it? As far as I know I can't tell compiler to replace errors with warnings. Using --std=c++14 is not an option because I want to use new features from C++1z.

推荐答案

由于 P0003 .在此之前,自C ++ 11起不推荐使用它们.它们不再是该语言的一部分,因此实际上没有解决它的方法.只要您需要该第三方库,直到它发生更改,您就只能使用C ++ 14.

C++17 removed dynamic exception specifications, as a result of P0003. Before that, they had been deprecated since C++11. They are no longer part of the language, so there isn't really a way to fix it. As long as you need that third party library, until it changes, you're stuck on C++14.

如果您不顾一切,可以尝试:

If you're desperate, you could try:

#define throw(...)

但是我不推荐它.

这篇关于c ++ 1z动态异常规范错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 12:16
查看更多