gpt4 book ai didi

c++11 - CppuTest 使用 C++11 版本构建

转载 作者:行者123 更新时间:2023-12-03 06:58:05 25 4
gpt4 key购买 nike

在Ubuntu下安装了g++ 4.9.0(实验)版本(我正在使用该版本提供的某些功能)

构建代码时,我使用脚本中的 cmake,并且它可以正确构建。下面的gcc包含g++的安装路径(/mnt...)

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

现在,当我使用 CppuTest 为我的代码构建单元测试时,出现以下错误。

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

在 CppuTest makefile 中包含 CPPUTEST_CPPFLAGS += -std=c++1y。我猜想这个 makefile 中缺少一些标志,因为正如我所说,C++ 实验库在我的“常规”代码中正确构建。我缺少什么?

最佳答案

可能是包含问题,请参阅 CppUTest Manual - 部分与运算符新宏(STL!)冲突与我自己的重载冲突!

TL;DR

UncrosserTest 中,您的 CppUTest 之后添加包含内容。

而不是

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

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

关于c++11 - CppuTest 使用 C++11 版本构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37082675/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com