看<<C intefaces and implementations>>时看到__FILE__与__LINE__,不甚理解,于是乎查了下。
__FILE__与__LINE__是预定义的宏,实现了标准的编译器中均可使用这些宏
__FILE__宏输出的是当前输入文件的路径,含文件名,而__LINE__宏输出当前代码所在的行号(整数变量)
以下文字部分引用自http://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html
__FILE__
"/usr/local/include/myheader.h"
is a possible expansion of this macro.
__LINE__
__FILE__
and __LINE__
are useful in generating an error message to report an inconsistency detected by the program; the message can state the source line at which the inconsistency was detected. For example,
fprintf (stderr, "Internal error: " "negative string length " "%d at %s, line %d.", length, __FILE__, __LINE__);
#include<stdio.h> int main(){ printf("%s\n",__FILE__); printf("%d\n",__LINE__); return 0; }