將我們的C++代碼從VS2008遷移到VS2010時遇到問題。到目前爲止,我找不到解釋它的原因,並會感謝您的幫助。VS2008到VS 2010的遷移 - 一個突破性的變化?
我們有一個自定義內存分配器,它駐留在一個dll中。在其餘的代碼中,我們使用預處理器將分配重定向到我們的函數。以下簡單的代碼在VS2008中正確編譯,但不在VS2010中。
在stdafh.h:
#define free my_free
#include <string>
在VS2010我得到:
1>d:\program files\microsoft visual studio 10.0\vc\include\xdebug(62): error C3861: 'free': identifier not found
從線出發:
template<class _Ty>
void __CLRCALL_OR_CDECL _DebugHeapDelete(_Ty *_Ptr)
{ // delete from the debug CRT heap even if operator delete exists
if (_Ptr != 0)
{ // worth deleting
_Ptr->~_Ty();
// delete as _NORMAL_BLOCK, not _CRT_BLOCK, since we might have
// facets allocated by normal new.
free(_Ptr);
任何幫助或想法將不勝感激!
摩西
,因此看起來您不會影響STL中的內容。因此,在包含字符串後加上#define。 – 2011-03-30 20:42:27