本文介绍了升压在VS2010防爆preSS - 重新定义和无效的调用约定错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用VS2010前preSS和刚刚安装升压v1_47。我已经加入了包括文件夹附加包含文件夹选项,也是'库'文件夹复制到其他库在VS选项。

I am using VS2010 Express and just installed Boost v1_47. I have added the 'include' folder to 'additional include folders' option, and also the 'lib' folder to the 'additional libraries' option in VS.

然后,我包括提升/ regex.hpp在我的文件中的一个,但实际上写道使用boost还没有code。然而,构建解决方案时,我得到很多的错误消息,在两种风格来:

Then, I included boost/regex.hpp in one of my files, but actually wrote no code using boost yet. However, when building the solution I get lots of error messages, coming in two flavours:


  • Redefiniton错误,如:

1> D:\\提升\\ boost_1_47 \\升压/细节/ interlocked.hpp(83):错误C2373:'_InterlockedCompareExchangePointer':重新定义;不同类型修饰符
1> C:\\ Program Files文件\\微软的SDK \\ WINDOWS \\ V7.1 \\包括\\ WINNT.H(2597):参见_InterlockedCompareExchangePointer的声明

1>D:\boost\boost_1_47\boost/detail/interlocked.hpp(83): error C2373: '_InterlockedCompareExchangePointer' : redefinition; different type modifiers1> C:\Program Files\Microsoft SDKs\Windows\v7.1\include\winnt.h(2597) : see declaration of '_InterlockedCompareExchangePointer'


  • 无效的调用约定错误(大量的这些),如:

D:\\提升\\ boost_1_47 \\升压/正则表达式/ V4 / regex_traits_defaults.hpp(271):错误C3641:提振:: re_detail :: global_lower:无效的调用约定__cdecl的使用/ clr编译功能:纯或/ CLR:安全

D:\boost\boost_1_47\boost/regex/v4/regex_traits_defaults.hpp(271): error C3641: 'boost::re_detail::global_lower' : invalid calling convention '__cdecl ' for function compiled with /clr:pure or /clr:safe

请注意:我还没有明确列入WINNT.H在我的任何源/头文件,并试图去激活pre-编译头和删除stdafx.h中包括,但它并没有解决问题

Note: I haven't explicitly included winnt.h in any of my source/header files, and have tried de-activating pre-compiled headers and removing the stdafx.h includes, but it didn't solve the problem.

这是怎么回事?

在此先感谢

推荐答案

您必须确保您使用相同的设置作为升压编译程序。
好像你使用了错误的项目模板(CLR东西)来创建应用程序项目。

You have to make sure that you compile your program with the same settings as boost.It seems like you used the wrong project template (CLR something) to create your application project.

您可以尝试修改现有项目的属性,使其与升压兼容,但 CLR ... 的项目有很多默认设置不兼容的属性值,所以我觉得最简单的办法是从头开始创建一个新的项目(和导入现有的code)。

You could try to modify the properties of your existing project to make it compatible with boost, but the CLR ... projects have lots of incompatible property values set by default, so i think the easiest way would be to create a new project from scratch (and import your existing code).

您应该使用空项目模板并创建一个新的项目,然后将现有的源和头文件添加到它,并添加再次提振包含路径,以及任何需要提升的.lib文件添加到项目性状>链接>输入>附加依赖(大部分Boost库工作开箱即用无需添加任何连接器的输入,因为他们只是头,所以你可能不需要添加任何的.libs)。

You should use the "Empty Project" template and create a new project, and then add your existing source and header files to it, and add the boost include path again, and add any required boost .lib files to Project Properties > Linker > Input > Additional Dependencies (Most boost libraries work out of the box without adding anything to linker inputs because they are header only, so you might not need to add any .libs).

升压是一个C ++要求,设计成由C ++ code,而不是C ++ / CLI code被消耗,因此,它只能与本地C ++类中使用,并包含在当大多数boost头文件会产生头一个源文件,其中包含C ++ / CLI code。

Boost is a C++ required, designed to be consumed by C++ code, not C++/CLI code, thus it can only be used with native C++ classes, and most boost headers will produce headers when included in a source file which contains C++/CLI code.

这篇关于升压在VS2010防爆preSS - 重新定义和无效的调用约定错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 02:24