当前位置:网站首页>C语言的内置宏(定义日志宏)
C语言的内置宏(定义日志宏)
2022-08-09 06:29:00 【qq_36412526】
我们在写C语言程序的时候,会经常用到宏定义,C语言也有很多内置的宏。
强大的内置宏:
我们再来写一个定义日志宏的程序感受一下。
#include <stdio.h>
#define LOG(s) do {
\ printf("%s %s [%s:%d] %s\n", __DATE__,__TIME__,__FILE__,__LINE__,s);\ }while(0)
void f(){
LOG("Enter f()...");
LOG("Exit f()...");
}
int main(){
LOG("Enter main()...");
f();
LOG("Exit main()...");
return 0;
}
运行看看效果:
看到运行结果,是不是感觉很熟悉啊,我们用的编译器的编译信息不都是这样的吗。以后写代码,这样写log信息或是调试,是不是很方便就可以定位啊,又get到一手啊。
边栏推荐
猜你喜欢
Error jinja2.exceptions.UndefinedError: 'form' is undefined
Gao Zelong, a famous digital collection expert and founder of the Digital Collection Conference, was interviewed by China Entrepreneur Magazine
db.sqlite3 has no "as Data Source" workaround
e-learning summary
[email protected]@BSABiS nanoparticles) | dendrimer-stabilized bismuth sulfide nanop"/>
Ferric oxide/bismuth sulfide nanocomposites ([email protected]@BSABiS nanoparticles) | dendrimer-stabilized bismuth sulfide nanop
Introduction of convenient functions and convenient shortcut keys of vs tomato assistant
Harbor Enterprise Mirror Warehouse Construction
Likou Brush Question 180
vs番茄助手的方便功能和便捷快捷键介绍
报错:FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disab
随机推荐
Text String Length Sorting - Online Tool
常用Oracle命令
中英文说明书丨TRC D-阿卓糖(D-Altrose)
Superparamagnetic iron [email protected]@cadmium sulfide nanocore-shell structure material|Fe3O4 magnetic nanop
05 多线程与高并发 - ThreadPoolExecutor 源码解析
C语言实现顺序栈和链队列
crc计算
jdepend
GNNExplainer应用于节点分类任务
报错:FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS重大开销和将disab补充道
sql问题解答创建表的语句
VS2019常用快捷键
MongDb的查询方式
io.lettuce.core.RedisCommandTimeoutException Command timed out
uniapp实现防抖搜索
锁执行的过程
static静态关键字和继承
简单使用Lambda表达式
Flask failed to create database without error
缓存技术使用