当前位置:网站首页>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__ ) );
边栏推荐
猜你喜欢
Vert. x: A simple login access demo (simple use of router)
MySQL数据库面试题
Software I2C based on Hal Library
Small L's test paper
[CDH] cdh5.16 configuring the setting of yarn task centralized allocation does not take effect
[Blue Bridge Cup 2017 preliminary] grid division
MongoDB
电商数据分析--用户行为分析
Face recognition_ recognition
Word排版(小计)
随机推荐
机器学习--决策树(sklearn)
Vert. x: A simple login access demo (simple use of router)
Matlab learning and actual combat notes
Valentine's Day flirting with girls to force a small way, one can learn
【CDH】CDH5.16 配置 yarn 任务集中分配设置不生效问题
Principle and implementation of MySQL master-slave replication
[BSidesCF_2020]Had_ a_ bad_ day
【yarn】CDP集群 Yarn配置capacity调度器批量分配
MTCNN人脸检测
[MRCTF2020]套娃
TypeScript
5G工作原理详解(解释&图解)
Vs2019 desktop app quick start
Those commonly used tool classes and methods in hutool
Kaggle竞赛-Two Sigma Connect: Rental Listing Inquiries
FTP文件上传文件实现,定时扫描文件夹上传指定格式文件文件到服务器,C语言实现FTP文件上传详解及代码案例实现
Hutool中那些常用的工具类和方法
Detailed explanation of nodejs
4、安装部署Spark(Spark on Yarn模式)
分布式节点免密登录