g ++ 4.7.2上的-std = c ++ 11的CppUTest错误

时间:2013-08-01 03:08:26

标签: c++11 cpputest g++-4.7

我一直在使用CppUTest与g ++ 4.7.2一段时间没有问题。但是,我刚刚打开-std=c++11选项,因此我可以开始使用std::unique_ptr并立即失败。

即使只是编译主模块:

#include <CppUTest/CommandLineTestRunner.h>

int main(int argc, char ** argv) {
    return CommandLineTestRunner::RunAllTests(argc, argv);
}

因以下情况而失败:

In file included from /usr/include/CppUTest/TestHarness.h:77:0,
                 from /usr/include/CppUTest/CommandLineTestRunner.h:31,
                 from tests/testmain.cpp:15:
/usr/include/CppUTest/MemoryLeakWarningPlugin.h:56:53: error: declaration of ‘void* operator new(size_t) throw (std::bad_alloc)’ has a different exception specifier
In file included from /usr/include/c++/4.7/ext/new_allocator.h:34:0,
                 from /usr/include/c++/4.7/x86_64-linux-gnu/bits/c++allocator.h:34,
                 from /usr/include/c++/4.7/bits/allocator.h:48,
                 from /usr/include/c++/4.7/string:43,
                 from /usr/include/CppUTest/SimpleString.h:136,
                 from /usr/include/CppUTest/Utest.h:34,
                 from /usr/include/CppUTest/TestHarness.h:71,
                 from /usr/include/CppUTest/CommandLineTestRunner.h:31,
                 from tests/testmain.cpp:15:
/usr/include/c++/4.7/new:93:7: error: from previous declaration ‘void* operator new(std::size_t)’

删除-std=c++11选项可以使一切正常工作。

CppUTest文档对与重载的新运算符冲突的宏做了一些评论,并建议首先包括#including标准标题,但是我得到了这个问题而根本没有包含任何标题,尽管它看起来像CppUTest/CommandLineTestRunner.h包括<string>本身。

之前有人遇到此问题或知道问题是什么?

0 个答案:

没有答案