The name of the current source file. __FILE__ expands to a string surrounded by double quotation s.如果定义_DEBUG 定义 new为 DEBUG_NEW 取消定义THIS_FILE static char THIS_FILE[] = __FILE__; 结束#ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif
定义 new为 DEBUG_NEW
取消定义THIS_FILE
static char THIS_FILE[] = __FILE__;
结束#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
THIS_FILE是用在DEBUG_NEW里
为什么不直接用new(__FILE__, __LINE__),因为较旧的编译器(如VC6.0)没有字符串池优化,可能会造成编译文件较大,所以用static char THIS_FILE[]声明唯一的副本
新版的(VS2005、2008、2010、2012)已经声明#define THIS_FILE __FILE__