我一直在使用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>
本身。
之前有人遇到此问题或知道问题是什么?