当前位置:网站首页>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__ ) );
边栏推荐
猜你喜欢

MongoDB

MySQL and C language connection (vs2019 version)

PyTorch四种常用优化器测试

MySQL realizes read-write separation
![[Blue Bridge Cup 2017 preliminary] grid division](/img/e9/e49556d0867840148a60ff4906f78e.png)
[Blue Bridge Cup 2017 preliminary] grid division

Vs2019 use wizard to generate an MFC Application
![[yarn] CDP cluster yarn configuration capacity scheduler batch allocation](/img/85/0121478f8fc427d1200c5f060d5255.png)
[yarn] CDP cluster yarn configuration capacity scheduler batch allocation

Small L's test paper

IOT system framework learning

Pytoch Foundation
随机推荐
2020 WANGDING cup_ Rosefinch formation_ Web_ nmap
Hutool中那些常用的工具类和方法
Mysql的索引实现之B树和B+树
ES6 let and const commands
Vert. x: A simple login access demo (simple use of router)
2019 Tencent summer intern formal written examination
[Kerberos] deeply understand the Kerberos ticket life cycle
[Blue Bridge Cup 2017 preliminary] buns make up
小L的试卷
机器学习--决策树(sklearn)
互联网协议详解
Vert. x: A simple TCP client and server demo
L2-006 tree traversal (25 points)
[BSidesCF_2020]Had_a_bad_day
E-commerce data analysis -- User Behavior Analysis
STM32型号与Contex m对应关系
【flink】flink学习
【Flink】CDH/CDP Flink on Yarn 日志配置
Those commonly used tool classes and methods in hutool
Machine learning -- linear regression (sklearn)