Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/155.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ boost.future导致clr出现问题_C++_Visual Studio 2012_Boost_Clr - Fatal编程技术网

C++ boost.future导致clr出现问题

C++ boost.future导致clr出现问题,c++,visual-studio-2012,boost,clr,C++,Visual Studio 2012,Boost,Clr,我正在使用visual studio 2012和需要链接到本机库的clr库。 我的库正在使用boost::future 当我对托管项目使用future::then(F&&)函数时,我遇到了这个问题: Error 910 error LNK2022: metadata operation failed (8013119F) : A TypeRef exists which should, but does not, have a corresponding TypeDef: (d

我正在使用visual studio 2012和需要链接到本机库的clr库。 我的库正在使用boost::future

当我对托管项目使用future::then(F&&)函数时,我遇到了这个问题:

Error   910 error LNK2022: metadata operation failed (8013119F) : A TypeRef exists which        should, but does not, have a corresponding TypeDef: (dummy): (0x0100003e).  D:\ClrProject\somefile.obj
正如在其他问题中所建议的那样,我试图使库中的
dummy
类型完整,因为我无法从模板内部正向声明嵌套结构,这可以通过
boost::thread::dummy
struct实现

这并没有解决问题

我的设置如下所示:

  • 增加1.55
  • 使用boost.dll
  • 定义BOOST\u结果\u使用\u DECLTYPE
  • 定义BOOST\u线程\u提供未来
  • 定义BOOST\u线程\u提供\u未来\u延续
我也在dependent.dll上使用这些非常重要的定义,以确保API的所有部分都正确地公开。

@汉斯·帕桑你的建议是对的。我只是没有把
#pragma
放在正确的地方

我必须放置pragmas,以便我的头被编译为非托管代码。完成后,我的代码的模板实例化似乎是以非托管方式发出的。在这一点上,问题消失了

所以我所做的是这样的:

#pragma managed(push, off)
#include "MyHeaderWithFutures.h"
#pragma managed(pop)

void f() {
   //
   f = myObject.Something().then(...);
}

只是不要在/clr有效的情况下编译Boost代码。或者用#pragma managed在飞行中关闭它。C++/CLI编译器只能将C++03代码转换为MSIL。如果您需要更多帮助,请发布一个代码片段。不幸的是,它不起作用。我尝试在我的dll和使用此库的/clr dll中使用相同的#define。我试图#pragma管理使用boost::future的.cpp文件,但typeref问题仍然存在。