[英]Errors when compiling catch with Visual Studio 2008
Update: using catch 1.9.7 solved this problem. 更新:使用catch 1.9.7解决了此问题。
I am just getting started with using catch and have been unable to get even a simple test project to compile. 我刚刚开始使用catch,甚至无法获得一个简单的测试项目进行编译。 I am using Visual Studio 2008 and have catch.hpp v1.10.0 (single file version). 我正在使用Visual Studio 2008,并且具有catch.hpp v1.10.0(单个文件版本)。
I created a simple test project following the catch tutorial. 我按照catch教程创建了一个简单的测试项目。 main.cpp is the only file and the code consists of: main.cpp是唯一的文件,代码包括:
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
TEST_CASE("test case 1")
{
REQUIRE(1==2);
}
I get the following errors when I compile: 编译时出现以下错误:
c:\utilities\catch\catchtest\catchtest\catch.hpp(1333) : warning C4181: qualifier applied to reference type; ignored
c:\utilities\catch\catchtest\catchtest\catch.hpp(1838) : see reference to class template instantiation 'Catch::Internal::Evaluator<T1,T2,Op>' being compiled
with
[
T1=const int &,
T2=const int &,
Op=IsEqualTo
]
c:\utilities\catch\catchtest\catchtest\catch.hpp(1836) : while compiling class template member function 'void Catch::BinaryExpression<LhsT,Op,RhsT>::endExpression(void) const'
with
[
LhsT=const int &,
Op=IsEqualTo,
RhsT=const int &
]
c:\utilities\catch\catchtest\catchtest\main.cpp(8) : see reference to class template instantiation 'Catch::BinaryExpression<LhsT,Op,RhsT>' being compiled
with
[
LhsT=const int &,
Op=IsEqualTo,
RhsT=const int &
]
c:\utilities\catch\catchtest\catchtest\catch.hpp(1333) : error C2529: 'lhs' : reference to reference is illegal
c:\utilities\catch\catchtest\catchtest\catch.hpp(1333) : warning C4181: qualifier applied to reference type; ignored
c:\utilities\catch\catchtest\catchtest\catch.hpp(1333) : error C2529: 'rhs' : reference to reference is illegal
c:\utilities\catch\catchtest\catchtest\catch.hpp(1838) : error C2664: 'Catch::Internal::Evaluator<T1,T2,Op>::evaluate' : cannot convert parameter 1 from 'const int' to 'const int &(&)'
with
[
T1=const int &,
T2=const int &,
Op=IsEqualTo
]
c:\utilities\catch\catchtest\catchtest\catch.hpp(1839) : error C2228: left of '.endExpression' must have class/struct/union
Any assistance would be much appreciated. 任何帮助将不胜感激。 I haven't been able to find anything in the catch documentation or online and am eager to get started with it. 我无法在渔获文件中或网上找到任何东西,因此很想开始使用。
The latest master of Catch is for modern C++ compiler and the Visual Studio 2008 compiler is pretty old now. 最新的Catch大师适用于现代C ++编译器,而Visual Studio 2008编译器现在已经相当老了。 There's some switches you can use to downgrade some of the features: 您可以使用一些开关来降级某些功能:
https://github.com/philsquared/Catch/blob/master/docs/configuration.md https://github.com/philsquared/Catch/blob/master/docs/configuration.md
Try it with 'CATCH_CONFIG_NO_CPP11' defined before #include'ing catch. 在#include'捕获之前,使用定义的“ CATCH_CONFIG_NO_CPP11”进行尝试。
供将来参考: 此提交和还原b6e7c9bd7a160c07c5de894292022687687895c17a3(在其顶部完成)已破坏了对MSVC 9的支持,然后这一步骤足以解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.