当前位置:网站首页>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到一手啊。
边栏推荐
- db.sqlite3 has no "as Data Source" workaround
- Xilinx Zynq ZynqMP DNA
- [MySQL] Second, the relationship between processes, MySQL password cracking, table building and database building related commands
- Qt 学习(三) —— Qt 模块
- kubernetes security
- XxlJobConfig分布式定时器任务管理XxlJob配置类,替代
- mongo+ycsb性能测试及线程数分析
- 6 states of a thread
- Regular Expression - Determine if a string matches the "AABB" pattern
- 安装flask
猜你喜欢
- [email protected]@cadmium sulfide nanocore-shell structure material|Fe3O4 magnetic nanop"/>
Superparamagnetic iron [email protected]@cadmium sulfide nanocore-shell structure material|Fe3O4 magnetic nanop
SiO2 / KH550 modified ferroferric oxide nano magnetic particles | PDA package the ferromagnetic oxide nanoparticles (research)
Inception V3 闭眼检测
Fragments
治疗消化性溃疡—Toronto Research Chemicals 甘氨酸铝
Magnetic Core-Shell Fe3O4 Particles Supported Gold Nanostars | Magnetic Fe3O4-POSS-COOH | Superparamagnetic Fe3O4-Polydopamine Core-Shell Nanoparticles
Search 1688 product interface by image (item_search_img-search 1688 product by image (Politao interface) code docking tutorial
PDF不能打印和复制的问题如何解决?
Output method of list string print(*a) print(““.join(str(c) for c in a) )
中英文说明书丨CalBioreagents 醛固酮单克隆抗体
随机推荐
Teach you how to make the Tanabata meteor shower in C language - elegant and timeless (detailed tutorial)
中英文说明书丨TRC 交替醇(Catalogue NumberA575760)
带头双向循环链表的增删查改(C语言实现)
默默重新开始,第一页也是新的一页
报错:FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disab
C# 利用iTextSharp画PDF
io.lettuce.core.RedisCommandTimeoutException Command timed out
Simple Factory Pattern
报错:flask: TypeError: ‘function‘ object is not iterable
How to find package information and pin definitions for NXP S32K1xx series microcontrollers
Reverse Engineering
golang zip aes base64
[R language] interaction test data
zip压缩包密码解密
jdepend
C语言实现顺序栈和链队列
Output method of list string print(*a) print(““.join(str(c) for c in a) )
install flask
idea中PlantUML插件使用
输入框最前面添加放大镜&&background-image和background-color冲突问题