C标准中一些预定义的宏

 C标准中指定了一些预定义的宏,对于编程经常会用到。下面这个表中就是一些常常用到的预定义宏。
  (双下滑线)      意义
  __DATE__  进行预处理的日期(“Mmm dd yyyy”形式的字符串文字)
  __FILE__   代表当前源代码文件名的字符串文字
  __LINE__  代表当前源代码中的行号的整数常量
  __TIME__  源文件编译时间,格式微“hh:mm:ss”
  __func__   当前所在函数名
  
对于__FILE__,__LINE__,__func__这样的宏,在调试程序时是很有用的,因为你可以很容易的知道程序运行到了哪个文件的那一行,是哪个函数。
   下面一个例子是打印上面这些预定义的宏的。
  #include <stdio.h>
  #include <stdlib.h>
  void why_me();
  int main()
  {
   printf( "The file is %s. ", __FILE__ );
   printf( "The date is %s. ", __DATE__ );
   printf( "The time is %s. ", __TIME__ );
   printf( "This is line %d. ", __LINE__ );
   printf( "This function is %s. ", __func__ );
   
   why_me();
   
   return 0;
  }
  void why_me()
  {
   printf( "This function is %s ", __func__ );
   printf( "The file is %s. ", __FILE__ );
   printf( "This is line %d. ", __LINE__ );
  }

原文地址:https://www.cnblogs.com/chris-cp/p/3517144.html