- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在尝试使用 g++ 4.8 重新编译一个巨大的遗留应用程序,以便调试 glibc 检测到的内存损坏
问题(使用 AddressSanitizer)。之前我们使用的是 g++ 4.4.7。
但是,编译失败:
/opt/rh/devtoolset-2/root/usr/include/c++/4.8.2/bits/exception_ptr.h:40:4: error: #error This platform does not support exception propagation.
在编译自定义异常处理程序时(我猜)。自定义异常处理程序仅在一处使用 exception_ptr
:
void reportOtherException(void) const
{
std::exception_ptr p = std::current_exception();
std::string s = (p != 0 ? p.__cxa_exception_type()->name() : "null");
printf("DvMain Bad Exception: '%s'\n", s.c_str());
mErrorReporter(0, DvLog::WARNING, 0, Dv::NO_PROFILE, 0, DvLog::UNHANDLED_OTHER_EXCEPTION);
}
而reportOtherException()
是这样使用的:
try
{
// Catch and log uncaught exceptions, then exit.
catch (const std::bad_exception& e) { exHandler.reportBadException(e); }
catch (const std::exception& e) { exHandler.reportStandardException(e); }
catch (...) { exHandler.reportOtherException(); }
}
我是 C++ 的新手,甚至不知道错误的含义。适用于 4.4.7,不适用于 4.8。
关于在 4.8 上编译需要更改什么的任何指示?
编辑我
这里有一些额外的信息:
g++ --version
g++ (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15)
最低代码
DvComDefaultExceptionHandler_test.h
#include "DvCommon.h"
#include "evt/DvEvt.h"
#include "log/DvLog.h"
#include "com/DvComErrorReporter.h"
#include <new>
#include <exception>
#include <sys/time.h>
#include <sys/resource.h>
#include <stdlib.h>
#include <unistd.h>
#include <malloc.h>
#include <bits/exception_ptr.h>
class DvComDefaultExceptionHandler
{
public:
DvComDefaultExceptionHandler(const DvComErrorReporter& er) {}
~DvComDefaultExceptionHandler() { }
void reportOtherException(void) const
{
std::exception_ptr p = std::current_exception();
}
private:
static const DvComDefaultExceptionHandler* mpInstance;
};
DvComDefaultExceptionHandler_test.cpp
#include "DvCommon.h"
#include "com/DvComDefaultExceptionHandler_test.h"
// Pointer to the single instance of the DvComDefaultExceptionHandler class.
const DvComDefaultExceptionHandler*
DvComDefaultExceptionHandler::mpInstance = 0;
编译命令和输出
g++ -c -g -O0 -DDEBUG -Wall -Wextra -Wno-sign-compare -Wcast-align
--ftemplate-depth-32 -march=native -ggdb -fPIC -Iinclude -I../../include
-I../../src -I/usr/include/libxml2 -D_GNU_SOURCE
-I/mnt/swdevel/DVMon/source_build/ext/ACE -D__ACE_INLINE__
-I/usr/local/include -I/usr/lib/qt-3.3/include
-o DvComDefaultExceptionHandler.o DvComDefaultExceptionHandler_test.cpp
In file included from ../../include/com/DvComDefaultExceptionHandler_test.h:76:0,
from DvComDefaultExceptionHandler_test.cpp:13:
/opt/rh/devtoolset-2/root/usr/include/c++/4.8.2/bits/exception_ptr.h:40:4: error: #error This platform does not support exception propagation.
# error This platform does not support exception propagation.
编辑二
跟踪包含文件归结为 __GCC_ATOMIC_INT_LOCK_FREE 的值。运行这个简单的程序会打印“2”作为 __GCC_ATOMIC_INT_LOCK_FREE 的值。
int
main(int argc, char **argv)
{
printf("__GCC_ATOMIC_INT_LOCK_FREE = %d\n", __GCC_ATOMIC_INT_LOCK_FREE);
}
G++ 版本:
$ g++ --version
g++ (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15)
编辑二
我已经在 Centos 7 VM 上运行的 g++ 6.3.1 上进行了尝试。还是一样的问题。
源文件 - 仅一行
#include <bits/exception_ptr.h>
编译命令:g++ -c -o test.o test.cpp
最佳答案
首先包括<bits/exception_ptr.h>
直接在技术上不受支持。它在头文件中是这么说的。这或多或少是偶然在 GCC 4.4 中起作用的。这个头文件的 C++11 迁移破坏了它,因为命名空间的原因,C++98 代码不能使用 ATOMIC_INT_LOCK_FREE
宏,标题不再起作用。
在 GCC 7 中,这已作为此错误的一部分修复(再次意外):
包含 <bits/exception_ptr.h>
的技巧直接应该在这个版本中再次工作。
这意味着您的选择是:
std::exception_ptr
在不透明类型中,在 C++11 或更高版本的模式下编译其实现,并将系统的其余部分保持在 C++98 模式。使用另一种 hack,比如这个:
#include <exception>
#ifndef ATOMIC_INT_LOCK_FREE
# define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE
#endif
#include <bits/exception_ptr.h>
同样,这完全不受支持,但它应该不会比您今天拥有的(使用 GCC 4.4)差多少。
关于c++ - 升级到 G++ 4.8 - exception_ptr.h 不支持异常传播,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45400971/
我尝试在安装了多类型 MFC 库的 visual studio 2015 MFC 上运行以前编写的 MFC c++ 代码。 但是,我这里仍然有 12 个关于缺少函数的错误: IntelliSense:
我正在学习 OOP 并且有疑问。假设我有一个包含 ClassB.h 的文件 ClassA.h,并且在某些时候我的 ClassB.h 需要包含 ClassA .h。 这会产生一个错误,我想我明白为什么会
我开始使用 CUDA 进行编程,在一些示例中我找到了包含文件 cuda.h、cuda_runtime.h 和 cuda_runtime_api.h 包含在代码中。有人可以向我解释一下这些文件之间的区别
我有一些生成正则表达式的代码。那么下面的表达式实际上是: ^(?:\s*((exclude|include|hide|show|protect|risk|dir-merge|merge)),\s*((
我一直在查看一些源代码,以更好地了解我们使用的这款游戏的核心,并编写更可靠、更快速的插件。然后我发现了这段奇怪的代码...... public void setMaxH(double amount)
通常我们会使用标准类型作为 std::unordered_map 的键和值.但现在我需要自定义我自己的键和值类。 键类在block_cache_key.h 中定义如下: #ifndef BLOCK_C
例如,我想要两个头文件,它们可以依赖于另一个头文件中的函数。 //Header1.h file #include Header2.h void h1(){ //... func1(); } v
我正在研究来自 Sedgewick 的 Shell 排序 Algorithms in C part 1-4在第 172 页。 我使用 size (数组的长度),而不是 l和 r (开始和结束);所以我
我在 macOS BigSur 上通过 VMWare 使用 Ubuntu 20.04.2 LTS。我安装了最新版本的 tcl、tcl-dev、tk 和 tk-dev - 版本 8.6。我想编译 Arc
我用我的 glu 和 gl 头文件构建了一个 OpenGL 程序,默认包含在 windows 7 专业版中。现在,我买了一本描述 OpenGL 游戏开发的书。这本书的作者说,我必须在我的项目中包含 g
我想在 token 中保留特殊字符,同时仍对特殊字符进行 token 化。说我有话 "H&R Blocks" 我想将其标记为 "H", "R", "H&R", "Blocks" 我读了http://w
关于 hash 作为 trans 参数的另一个问题。在下面的代码中,简单地使用 hash 会给出不正确的结果,但是将其替换为 keys 和 values 会使其正确。怎么了? my @alph1 =
我已经编写了一个 C 程序,它获取屏幕像素的 RGB 值 (0-255),并知道其位置 (x,y)。它可以在 Linux 中运行,但是当我尝试在 Visual Studio (Windows) 中编译
我已经使用 Windows 7 专业版中默认包含的 glu 和 gl 头文件构建了一个 OpenGL 程序。现在,我买了一本描述 OpenGL 游戏开发的书。这本书的作者说,我必须将glew head
#include using namespace std; #include //#include int main() { initscr();
h:messages h:form 内的组件还显示与外部组件相关的消息。 如何限制它只显示与包含 h:form 内的组件相关的消息? 我不喜欢用单独的h:message来使我的代码膨胀。每个输入组件的
我下载了示例代码和 cpp 文件,其中包含 list.h、queue.h 和 vector.h 等头文件,如果我尝试构建,我会收到“ fatal error :没有这样的文件或目录编译终止”我想我应该
我有一个编译成功的桌面项目,但是在我向项目添加新配置以支持 Windows Mobile 平台后,我收到以下错误: error C2146: syntax error : missing ';' be
有很多关于这个错误的帖子,但我无法解决它,我希望你能拿出解决方案。我在 Ubuntu 机器上。 ~/graphmap2$ 在这个文件夹中,我下载了 zlib。可以看图 经过一番谷歌搜索后,我还注意到没
是否可以在 Visual C++ 中使用以下 header : 图.h dos.h bios.h 最佳答案 据我所知,无法在 Visual C++ 中使用它, 与此同时,我希望您关注 Open Wat
我是一名优秀的程序员,十分优秀!