简体   繁体   English

使用Visual Studio 2008进行编译时出现错误

[英]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.

相关问题 Visual Studio 2008生成错误 - Visual Studio 2008 build errors Visual Studio 2019 C++ - 编译时错误报告错误 - Visual Studio 2019 C++ - incorrectly reporting errors when compiling 在Visual Studio 2008中编译MySQL自定义引擎 - Compiling MySQL custom engine in Visual Studio 2008 使用 Visual Studio 2008 编译和运行 MFC 应用程序? - Compiling and Running MFC Applications with Visual Studio 2008? 使用Visual Studio 2015编译OpenCV 2.4.12时出错 - Errors compiling OpenCV 2.4.12 with Visual Studio 2015 Visual Studio 2008在编译模板时不关心基类的存在吗? - Visual Studio 2008 does not care about base class existence when compiling templates? 使用Visual Studio 2008而不是使用g ++编译的与参考相关的问题 - Reference related issue compiling with Visual Studio 2008 but not with g++ 在Visual Studio 2008 Pro和标准版本中编译项目有什么区别吗? - Is there a difference between compiling projects in Visual Studio 2008 Pro and the Standard version? 发生某些错误时,如何防止Visual Studio 2008 C编译器停止? - How to prevent Visual Studio 2008 C compiler from stopping when some errors occur? 尝试使用Visual Studio 2008在Windows中编译qt-labs-qt3d时出错 - Getting errors when trying to compile qt-labs-qt3d in windows with visual studio 2008
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM