3

Installed g++ 4.9.0 (experimental) version under Ubuntu (I am using certain features provided by this version)

When building my code, I use cmake from a script, and it builds correctly. gcc below contains the path where g++ is installed (/mnt...)

$_cmake_ $_dir_ -DCMAKE_CXX_COMPILER=${_gpp_} -DCMAKE_C_COMPILER=${_gcc_} -DCMAKE_BUILD_TYPE=${_build_} -DCMAKE_INSTALL_PREFIX=${_install_} -DBUILD_TESTING:BOOL=1 

Now, when I make the CppuTest to build the Unit Tests for my code, I get the following error.

make all 
compiling UncrosserTest.cpp

In file included from /home/miguel/Desktop/Ugur/scmProject/scm/dist/dev/mfx_prod/scm/20160207/include/scm/services/primitives.hpp:4:0,
                 from /home/miguel/Desktop/Ugur/scmProject/log/lidya/src/cpp/scm/services/examples/dummy_strategy/Inside.hpp:6,
                 from AllTests/Uncrosser/UncrosserTest.cpp:7:
/usr/include/c++/4.9/experimental/optional: In member function ‘void std::experimental::_Optional_base<_Tp, _ShouldProvideDestructor>::_M_construct(_Args&& ...)’:
/usr/include/c++/4.9/experimental/optional:294:18: error: expected type-specifier
           ::new (std::__addressof(this->_M_payload))
                  ^
/usr/include/c++/4.9/experimental/optional:294:18: error: expected ‘)’
/usr/include/c++/4.9/experimental/optional: In member function ‘void std::experimental::_Optional_base<_Tp, false>::_M_construct(_Args&& ...)’:
/usr/include/c++/4.9/experimental/optional:424:18: error: expected type-specifier
           ::new (std::__addressof(this->_M_payload))
                  ^
/usr/include/c++/4.9/experimental/optional:424:18: error: expected ‘)’
make: *** [objs/AllTests/Uncrosser/UncrosserTest.o] Error 1

In the CppuTest makefile have included CPPUTEST_CPPFLAGS += -std=c++1y. I guess that am missing some flags in this makefile because as I said the C++ experimental library is building correctly in my "regular" code. What am I missing ?

Mostafiz
  • 7,243
  • 3
  • 28
  • 42

1 Answers1

0

Possible it's an include problem, see CppUTest Manual - section Conflicts with operator new macros (STL!) and Conflicts with my own overload!

TL;DR

In UncrosserTest add includes for CppUTest after your's.

Instead of

#include <CppUTest/TestHarnes.h>
#include "whatever.h"

do

#include "whatever.h"
#include <CppUTest/TestHarnes.h>
ollo
  • 24,797
  • 14
  • 106
  • 155