我在将我们的 C++ 代码从 VS2008 迁移到 VS2010 时遇到了问题。到目前为止,我找不到原因的解释,并感谢您的帮助。
我们有一个自定义内存分配器,它驻留在一个 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);
任何帮助或想法将不胜感激!
摩西