当前位置:网站首页>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.
边栏推荐
猜你喜欢
随机推荐
flask创建数据库失败未报错
线程池总结
Qt 学习(三) —— Qt 模块
DDD 领域驱动设计
shardingsphere data sharding configuration item description and example
Likou Brush Question 180
Flask failed to create database without error
APP product source data interface (taobao, jingdong/spelling/suning/trill platform details a lot data analysis interface) code and docking tutorial
Data center project preliminary summary
Reverse Engineering
Gao Zelong, a famous digital collection expert and founder of the Digital Collection Conference, was interviewed by China Entrepreneur Magazine
static静态关键字和继承
报错:FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS重大开销和将disab补充道
Search 1688 product interface by image (item_search_img-search 1688 product by image (Politao interface) code docking tutorial
Introduction and use of BeautifulSoup4
Altium designer软件常用最全封装库,包含原理图库、PCB库和3D模型库
ZIP压缩包文件删除密码的方法
Qt learning (3) - Qt module
TCP segment of a reassembled PDU
Unity五子棋游戏设计 和简单AI实现(1)