我正在试图在box2d游戏中使用提升。但是当我创建b2world时,会导致崩溃。用box2d提升
#include <Box2d/Box2D.h>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
namespace fs = boost::filesystem;
int main(int argc, char *argv[])
{
b2World *world = new b2World(b2Vec2(0.0f, -10.0f), true);
fs::path full_path(fs::initial_path<fs::path>());
delete world;
return 0;
}
当我用box2d或boost代码注释字符串时,它工作正常。但他们不想一起工作。
错误:Game.exe中0x5d9031ea(msvcr90d.dll)未处理的异常:0xC0000005:访问冲突读取位置0xccccccc0。
> msvcr90d.dll!operator delete(void * pUserData=0xcccccccc) Line 52 + 0x3 bytes C++
msvcp90d.dll!std::allocator<unsigned short>::deallocate(unsigned short * _Ptr=0xcccccccc, unsigned int __formal=3435973837) Line 146 + 0x9 bytes C++
msvcp90d.dll!std::basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> >::_Tidy(bool _Built=true, unsigned int _Newsize=0) Line 2168 C++
msvcp90d.dll!std::basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> >::~basic_string<unsigned short,std::char_traits<unsigned short>,std::allocator<unsigned short> >() Line 917 C++
Game.exe!boost::filesystem3::path::~path() + 0x2e bytes C++
Game.exe!main(int argc=1, char * * argv=0x003a4ca0) Line 32 + 0x19 bytes C++
Game.exe!__tmainCRTStartup() Line 582 + 0x19 bytes C
只生成调试模式。
无论我在哪里创建b2World对象:在full_path()之后或不是。即使我在项目中的另一个类或文件中创建了b2World对象,也会产生错误。
你会很快发现,如果你不包含超过“它崩溃”,我们通常不可能帮助调试你的错误。它如何崩溃?它会产生错误吗?你是否添加了一个断点来查看它是否通过某一行? –
msvcr90d.dll!运算符删除(void * pUs ...第52行 msvcp90d.dll!std :: allocat ...第146行+ 0x9字节 msvcp90d.dll!std :: basic_string,std :: allocator ,std :: allocator > ::〜 game_sys ,std :: allocator >()行917 Game.exe!boost :: filesystem3 :: path ::〜path() Game.exe! main(int argc = 1,char * * argv = 0x002e4ca0) 有调用堆栈,仅在调试模式下产生错误 –
Raman
@Raman:把它放在你的答案中并格式化它 –