当前位置:网站首页>Built-in macros in C language (define log macros)
Built-in macros in C language (define log macros)
2022-08-09 06:32:00 【qq_36412526】
When we write C language programs, we often use macro definitions. C language also has many built-in macros.
Powerful built-in macros:
Let's write a program that defines a log macro to get a feel for it.
#include #define LOG(s) do { \ printfspan>("%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;}
Run it to see the effect:
See it runAs a result, doesn't it feel very familiar? Isn't the compilation information of the compilers we use like this?When writing code in the future, it is very convenient to write log information or debug in this way.
边栏推荐
猜你喜欢
随机推荐
Unity backgammon game design and simple AI implementation (1)
无重复的字符的最长子串
Unity Gobang Game Design and Simple AI (2)
思维方法 解决问题的能力
6 states of a thread
缓存技术使用
DDD 领域驱动设计
Qt 学习(三) —— Qt 模块
crc calculation
字节跳动笔试题2020 (抖音电商)
untiy countdown
[R language] Normalize and organize files into folders of various file types
e-learning summary
IQ Products CMV Brite Turbo试剂盒的原理
golang xml 处理动态属性
Reverse Engineering
简单工厂模式
Unity五子棋游戏设计 和简单AI实现(1)
【Feel】In the Unity Feel plugin, Camera cannot display CameraShake correctly
运放-运算放大器经典应用电路大全-应用电路大全