当前位置:网站首页>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到一手啊。
边栏推荐
- [MySQL] Second, the relationship between processes, MySQL password cracking, table building and database building related commands
- INSTALL_RPATH and BUILD_RPATH problem in CMake
- Program Performance Analysis - Complexity Analysis
- 运放-运算放大器经典应用电路大全-应用电路大全
- Word文件的只读模式没有密码怎么退出?
- [MySQL]二、进程的关系、MySQL密码破解、建表和建库相关命令
- uniapp实现防抖搜索
- Getting started with kubernetes apparmor
- crc calculation
- Unity backgammon game design and simple AI implementation (1)
猜你喜欢
How to automatically fill down an excel table without dragging the mouse down
GNNExplainer应用于节点分类任务
CalBioreagents超全Id 蛋白兔单克隆抗体,助力科研
Data center project preliminary summary
pdf加密、找回密码
vs番茄助手的方便功能和便捷快捷键介绍
普罗米修斯原理及节点发布
Fragments
Unity C# 委托——事件,Action,Func的作用和区别
Adds, deletes, searches, and changes the leading doubly circular linked list (implemented in C language)
随机推荐
DevNet: Deviation Aware Networkfor Lane Detection
Reverse Engineering
【R语言】交互作用 测试数据
MongDb的查询方式
6 states of a thread
DDD 领域驱动设计
工控设备的系统如何进行加固
力扣刷题180
shardingsphere数据分片配置项说明和示例
报错:FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disab
带头双向循环链表的增删查改(C语言实现)
Qt learning (3) - Qt module
TCP segment of a reassembled PDU
crc计算
Can Jincang Database Set Transaction Automatic Commit?
逆向工程
The solution that does not work and does not take effect after VScode installs ESlint
Program Performance Analysis - Complexity Analysis
Service
vs番茄助手的方便功能和便捷快捷键介绍