当前位置:网站首页>C语言,log打印文件名、函数名、行号、日期时间
C语言,log打印文件名、函数名、行号、日期时间
2022-07-06 09:16:00 【薇远镖局】
• __LINE__:在源代码中插入当前源代码行号
• __FILE__:在源文件中插入当前源文件名
• __FUNCTION__:函数名
• __DATE__:在源文件中插入当前的编译日期
• __TIME__:在源文件中插入当前编译时间C语言使用printf(“filename:%s”, FILE);打印文件名,发现会将文件所在的目录也打印出来
#include <string.h> //strrchr()函数所需头文件
//windows:
#define filename(x) strrchr(x,'\\')?strrchr(x,'\\')+1:x
//linux :
#define filename(x) strrchr(x,'/')?strrchr(x,'/')+1:x
printf( "filename:%s\n", filename( __FILE__ ) );
边栏推荐
- 搞笑漫画:程序员的逻辑
- [yarn] yarn container log cleaning
- 4. Install and deploy spark (spark on Yan mode)
- 4、安装部署Spark(Spark on Yarn模式)
- [Flink] cdh/cdp Flink on Yan log configuration
- {one week summary} take you into the ocean of JS knowledge
- vs2019 使用向导生成一个MFC应用程序
- 使用LinkedHashMap实现一个LRU算法的缓存
- E-commerce data analysis -- User Behavior Analysis
- FTP文件上传文件实现,定时扫描文件夹上传指定格式文件文件到服务器,C语言实现FTP文件上传详解及代码案例实现
猜你喜欢

Small L's test paper

wangeditor富文本引用、表格使用问题

{one week summary} take you into the ocean of JS knowledge

Software I2C based on Hal Library

Vs2019 use wizard to generate an MFC Application

Variable star user module

MongoDB

B tree and b+ tree of MySQL index implementation

Composition des mots (sous - total)

电商数据分析--薪资预测(线性回归)
随机推荐
[NPUCTF2020]ReadlezPHP
Funny cartoon: Programmer's logic
IOT system framework learning
Vert. x: A simple TCP client and server demo
{one week summary} take you into the ocean of JS knowledge
树莓派 轻触开关 按键使用
[yarn] CDP cluster yarn configuration capacity scheduler batch allocation
Linux yum安装MySQL
Implementation scheme of distributed transaction
MySQL数据库面试题
jS数组+数组方法重构
Come and walk into the JVM
小L的试卷
Linux Yum install MySQL
Basic use of pytest
搞笑漫画:程序员的逻辑
vs2019 第一个MFC应用程序
Word排版(小计)
When using lambda to pass parameters in a loop, the parameters are always the same value
[Flink] Flink learning