我对 boost 和 .net-Framework 有疑问。我在没有.net 的情况下编写了我的课程。该项目运行良好,现在我将类文件包含到 Windows 窗体应用程序中。发生了许多编译器错误,例如“__declspec(dllexport) 无法与 /clr:pure 或 /clr:safe 一起使用”在 singleton.hpp(boost-library)中。我创建一个例子。在 Form1-header 中,仅包含此类,没有其他任何操作,仅来自 Visual Studio 2010 生成的代码。
这是一个测试类,我创建它是为了向您展示一个简单的案例:
#ifndef FOO_H
#define FOO_H
#include <boost/archive/xml_oarchive.hpp>
#include <boost/archive/xml_iarchive.hpp>
class Foo
{
private:
int name;
public:
void setName(int name);
int getName(void);
private:
friend boost::serialization::access;
template<class Archive>
void serialize (Archive& arch, const unsigned int)
{
arch & BOOST_SERIALIZATION_NVP(this->name);
}
};
#endif
我尝试将 /clr:pure 切换到 /clr,这样编译器可以编译它,但是在启动程序时发生了错误。它的标题是“调试断言失败!” 在 exe 文件中。在消息框中,您还可以阅读“Expression:_CrtIsValidHeapPointer(pUserData)” 目前我使用 boost 1.52.0,但我也尝试使用 boost 1.53.0。我用“bootstrap.bat”和“bjam.exe”安装了boost。
有人知道这个问题的解决方案吗?