VC 中的 __FILE__ 宏

VC 中有一个 __FILE__ 宏定义,表示当前文件,比如,下面的程序就可以输出编译期的源文件名。

#include "stdafx.h"
#include "stdio.h"

int _tmain(int argc, _TCHAR* argv[])
{
	printf(__FILE__);
	getchar();
	return 0;
}

 

我们在BIOS中经常看到的 ASSERT 就使用这个宏来准确的输出出现错误的位置。

此外,在 Release 模式下这个宏只包括文件名,Debug 模式下这个宏会输出完整的路径。

debug

release

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注