博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
c标准中的预定义宏
阅读量:4285 次
发布时间:2019-05-27

本文共 813 字,大约阅读时间需要 2 分钟。

ANSI C标准中有几个标准预定义宏: __LINE__:在源代码中插入当前源代码行号; __FILE__:在源文件中插入当前源文件名; __DATE__:在源文件中插入当前的编译日期 __TIME__:在源文件中插入当前编译时间;
__func__: 当前所在函数名,在编译器的较高版本中支持__FUNCTION__: 当前所在函数名

使用实例

#include 
#include
void why_me();int main(){ printf( "The file is %s.\n", __FILE__ ); printf( "The date is %s.\n", __DATE__ ); printf( "The time is %s.\n", __TIME__ ); printf( "This is line %d.\n", __LINE__ ); printf( "This function is %s.\n", __func__ ); why_me(); return 0;}void why_me(){ printf( "This function is %s\n", __func__ ); printf( "The file is %s.\n", __FILE__ ); printf( "This is line %d.\n", __LINE__ );}
运行结果

The file is debug.c.The date is Jun  6 2012.The time is 09:36:28.This is line 11.This function is main.This function is why_meThe file is debug.c.This is line 22.

转载地址:http://jmigi.baihongyu.com/

你可能感兴趣的文章
Android studio中快速try catch的快捷键
查看>>
Dialog 和 Toast
查看>>
队列在Http请求中的一点理解
查看>>
好想在你身边
查看>>
写给还在迷茫中挣扎的你
查看>>
在迷茫中执着前行
查看>>
笔记本连接无线但不能上网,网速极慢
查看>>
小蜗牛,慢慢爬
查看>>
Java关键字 -- Super
查看>>
Java -- 入口函数浅析
查看>>
EventBus 的简单使用
查看>>
Banner 浅析
查看>>
Android Crash框架Recovery
查看>>
限制 EditText 最多输入两位小数
查看>>
Android中attrs.xml文件的使用详解
查看>>
TabLayout 解析
查看>>
android获取屏幕尺寸、密度(判断手机屏幕类型)
查看>>
dpi 、 dip 、分辨率、屏幕尺寸、px、density 关系以及换算
查看>>
Android drawable 目录下不同精度 浅析
查看>>
Drawable 文件夹——xml文件
查看>>