CppUTest error with -std = C ++ 11 on g ++ 4.7.2

I have been using CppUTest with g ++ 4.7.2 for a while without problems. However, I just flipped the -std=c++11 parameter, so I can start using std::unique_ptr and it will work immediately.

Even just compiling the main module:

 #include <CppUTest/CommandLineTestRunner.h> int main(int argc, char ** argv) { return CommandLineTestRunner::RunAllTests(argc, argv); } 

does not work with changes:

 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)' 

Removing the -std=c++11 option makes everything beautiful again.

The CppUTest documentation gives some comments about macros that conflict with overloaded new operators, and suggests including standard headers first, but I get this problem without including any headers at all, although it looks like this: CppUTest/CommandLineTestRunner.h includes <string> >> itself .

Does anyone come across this before or know what the problem is?

+6
source share

Source: https://habr.com/ru/post/950773/


All Articles