Managed and unmanaged code error C3699

有些话、适合烂在心里 提交于 2019-12-13 07:23:52

问题


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

These kind of errors are in xmemory0 and list files? what they are? and it happend only for Obstacle class, the rest are fine.

Here it is part of the code

    void SetupObstacles(std::list<Cadet::Game::Entities::Obstacle>  &obstacles)
    {
     int size = CurrentLevel->Obstacles->Length;
     Cadet::XMLReader::Models::Obstacle^ currentObstacle;
  }

回答1:


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<>.

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)
    { ... }



回答2:


Do you have a pointer to an Obstacle somewhere?

The help on this error suggests that some types (such as trivial properties) cannot have a reference type--you can't have a pointer to it. Try using ^ instead.



来源:https://stackoverflow.com/questions/15314126/managed-and-unmanaged-code-error-c3699

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!