C语言的6个标准宏

引用自:http://www.cnblogs.com/hnrainll/archive/2012/08/15/2640558.html

ANSIC标准定义了以下6种可供C语言使用的预定义宏:
__LINE__ 在源代码中插入当前源代码行号
__FILE__ 在源代码中插入当前源代码文件名
__DATE__ 在源代码中插入当前编译日期〔注意和当前系统日期区别开来〕
__TIME__ 在源代码中插入当前编译时间〔注意和当前系统时间区别开来〕
__STDC__ 当要求程序严格遵循ANSIC标准时该标识符被赋值为1。
__cplusplus
标识符__LINE__和__FILE__通常用来调试程序;
标识符__DATE__和__TIME__通常用来在编译后的程序中加入一个时间标志,以区分程序的不同版本;
当要求程序严格遵循ANSIC标准时,标识符__STDC__就会被赋值为1;
当用C++编译程序编译时,标识符__cplusplus就会被定义。

复制代码
/* ************************************************************************
* Filename: test.c
* Description:
* Version: 1.0
* Created: 2011年07月21日 23时09分30秒
* Revision: none
* Compiler: gcc
* Author: YOUR NAME (),
* Company:
* ***********************************************************************
*/

#include
<stdio.h>

int main()
{

printf(
"this file name is:*%s*\n",__FILE__);
printf(
"this line number is:*%d*\n",__LINE__);
printf(
"this time is:*%s*\n",__TIME__);
printf(
"this date is:*%s*\n",__DATE__);
return0;
}
复制代码
原文地址:https://www.cnblogs.com/langqi250/p/2725899.html