天天看點

Physx使用的問題

1.提示NxUserAllocator::_malloc_dbg重聲明,重定義了

這種問題的發生是由于我們的工程使用了_CRTDBG_MAP_ALLOC用來進行記憶體溢出檢測。

該定義宏會導緻在crtdbg.h中定義如下宏

#define malloc(s) _malloc_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)

該宏會把malloc(size_t s)和malloc(size_t s, NxMemoryType type)都擴充成_malloc_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)。導緻重定義。

解決辦法:

在定義_CRTDBG_MAP_ALLOC之後,#include<crtdbg.h>之前,#include "NxPhysics.h"

繼續閱讀