我正在試圖在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:把它放在你的答案中並格式化它 –