托管和非托管代码错误C3699 [英] Managed and unmanaged code error C3699
问题描述
我正在开发一个使用C#和C ++的游戏。模型的类是用C#编写的,层级结构存储在XML文件中。当我想在C ++中读它,并希望构建项目我有这个奇怪的错误,我不在哪里找到一些错误。
I am working on a game which uses C# and C++. Classes for models are written in C# and levels structure is stored in XML files. When I want read it in C++ and want to build project I have this strange error and I don't where to find some bugs.
Error 1 error C3699: '*' : cannot use this indirection on type 'Cadet::XMLReader::Models::Obstacle' C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xmemory0 527 1 Cadet.Game
这些错误位于 xmemory0
和列表
文件?他们是什么?
These kind of errors are in xmemory0
and list
files? what they are? and it happend only for Obstacle class, the rest are fine.
这里是代码的一部分
void SetupObstacles(std::list<Cadet::Game::Entities::Obstacle> &obstacles)
{
int size = CurrentLevel->Obstacles->Length;
Cadet::XMLReader::Models::Obstacle^ currentObstacle;
}
推荐答案
$ c> Cadet :: Game :: Entities :: Obstacle 是一个托管类(因为你已经声明 currentObstacle
c $ c> ^ )。如果是这样,您不能在STL容器中直接存储托管对象,例如 std :: list<>
。
It looks like Cadet::Game::Entities::Obstacle
is a managed class (since you've declared currentObstacle
as a reference with ^
). If that's the case, you can't directly store managed objects in STL containers like std::list<>
.
很难说下一步做什么更多的上下文,但一个可能的解决方法是更改您的 SetupObstacles
方法:
It's hard to say what to do next w/o more context, but one possible fix would be to change your SetupObstacles
method:
void SetupObstacles(System::Collections::Generic::List<Cadet::Game::Entities::Obstacle>^ obstacles)
{ ... }
这篇关于托管和非托管代码错误C3699的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!