C/C++ Linux 终端 高亮调试

c 复制代码
#ifndef mydebug
// bg
#define ANSI_COLOR_BG_BLACK   "\x1b[40m"
#define ANSI_COLOR_BG_RED     "\x1b[41m"
#define ANSI_COLOR_BG_GREEN   "\x1b[42m"
#define ANSI_COLOR_BG_YELLOW  "\x1b[43m"
#define ANSI_COLOR_BG_BLUE    "\x1b[44m"
#define ANSI_COLOR_BG_MAGENTA "\x1b[45m"
#define ANSI_COLOR_BG_CYAN    "\x1b[46m"
#define ANSI_COLOR_BG_WHITE   "\x1b[47m"

// fg
#define ANSI_COLOR_FG_BLACK   "\x1b[30m"
#define ANSI_COLOR_FG_RED     "\x1b[31m"
#define ANSI_COLOR_FG_GREEN   "\x1b[32m"
#define ANSI_COLOR_FG_YELLOW  "\x1b[33m"
#define ANSI_COLOR_FG_BLUE    "\x1b[34m"
#define ANSI_COLOR_FG_MAGENTA "\x1b[35m"
#define ANSI_COLOR_FG_CYAN    "\x1b[36m"
#define ANSI_COLOR_FG_WHITE   "\x1b[37m"

// effect
#define ANSI_COLOR_BOLD         "\x1b[1m"
#define ANSI_COLOR_DIM          "\x1b[2m"
#define ANSI_COLOR_ITALIC       "\x1b[3m"
#define ANSI_COLOR_UNDERLINE    "\x1b[4m"
#define ANSI_COLOR_FLASE        "\x1b[5m"
#define ANSI_COLOR_ANTIWHITE    "\x1b[7m"
#define ANSI_COLOR_INVISIBLE    "\x1b[8m"

// end
#define ANSI_COLOR_RESET        "\x1b[0m"

// #define DEBUG_PRINT(variable) printf(ANSI_COLOR_YELLOW "Variable: %s\nValue: %d\nFile: %s\nLine: %d\nFunction: %s\n\n" ANSI_COLOR_RESET, #variable, variable, __FILE__, __LINE__, __func__)
#define DEBUG_PRINT(variable) printf(ANSI_COLOR_BOLD ANSI_COLOR_FG_YELLOW "F: %s, L: %d, F: %s, N: %s,V: %d\n" ANSI_COLOR_RESET, __FILE__, __LINE__, __func__, #variable, variable)
#endif

使用

c 复制代码
DEBUG_PRINT(n);
相关推荐
有只小白叫岳飒2 分钟前
c++智能指针 unique_ptr与函数调用
c++
Leo.yuan7 分钟前
Kafka+Flink拼凑,还是FineDataLink 5.0一体化?实时数据处理的两种思路
c++·mfc
Allocator12 分钟前
彻底解决ubuntu上腾讯会议无法共享问题
linux·ubuntu·腾讯会议
程序员-Benothing29 分钟前
Linux编码转换命令:iconv、dos2unix、base64、md5sum
linux·运维·服务器
重生之小比特32 分钟前
【Linux系统】06 进程概念
linux
2402_8828938641 分钟前
Linux 进程概念详解(上)—— 从冯诺依曼体系到僵尸进程与孤儿进程
linux·运维·服务器
qetfw1 小时前
Debian iptables 防火墙:默认拒绝、SNAT 与 DNAT 验证
linux·服务器·debian·php
老王爱玩车1 小时前
文件操作从打开到缓冲区
c语言·开发语言·学习
忆挽篱笙歌1 小时前
冯诺依曼+操作系统+进程
linux·ubuntu
INGNIGHT1 小时前
944 · 最大子矩阵(前缀和)
数据结构·c++·算法