__DATE__,__FILE__,__LINE__,__TIME__,__FUNCTION__

<p>C99 ( ISO/IEC 9899:1999) 网上有pdf文件。</p>
<div><br></div>
<p>
C标准中指定了一些预定义的宏,对于编程经常会用到。下面这个表中就是一些常常用到的预定义宏。<br><br>
__DATE__<br>
进行预处理的日期(“Mmm dd yyyy”形式的字符串<span><a id="vad_2" class="vLink1" style="font-size: 1em; border-bottom: 1px dotted #ff3366;" name="2" href="http://action.vogate.com/c/c.php?r=&aid=11511&sid=6235007045041189&click=1&url=http%3A//www.valca.com.cn/%3Fproduct-951.html&v=0&k=%u6587%u5B57&s=http%3A//www.programfan.com/article/2883.html&rn=313520" target="_blank">文字</a>
</span>
)<br><br>
__FILE__<br>
代表当前源代码文件名的字符串文字<br><br>
__LINE__<br>
代表当前源代码中的行号的整数常量<br><br>
__TIME__<br>
源文件编译时间,格式微“hh:mm:ss”<br><br>
__FUNCTION__(__fucn__)<br>
当前所在函数名 <br><br><br>
对于__FILE__,__LINE__,__func__这样的宏,在调试程序时是很<span><a id="vad_3" class="vLink1" style="font-size: 1em; border-bottom: 1px dotted #ff3366;" name="3" href="http://action.vogate.com/c/c.php?r=&aid=11514&sid=6235007045041189&click=1&url=http%3A//www.valca.com.cn/%3Fproduct-68.html&v=0&k=%u6709%u7528&s=http%3A//www.programfan.com/article/2883.html&rn=263010" target="_blank">有用</a>
</span>
的,因为你可以很容易的知道程序运行到了哪个文件的那一行,是哪个函数。<br><br>
下面一个例子是打印上面这些预定义的宏的。 <br><br><br>
#include <stdio.h><br>
#include <stdlib.h><br>
void why_me();<br>
int main()<br>
{<br>
printf( "The file is %s./n", __FILE__ );<br>
printf( "The date is %s./n", __DATE__ );<br>
printf( "The time is %s./n", __TIME__ );<br>
printf( "This is line %d./n", __LINE__ );<br>
printf( "This function is %s./n", __FUNCTION__ );<br>
why_me();<br>
return 0;<br>
}<br><br>
void why_me()<br>
{<br>
printf( "This function is %s/n", __func__ );<br>
printf( "The file is %s./n", __FILE__ );<br>
printf( "This is line %d./n", __LINE__ );<br>
}






</p>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值