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);
相关推荐
八月的雨季 最後的冰吻5 分钟前
SIP协议栈--osip源码梳理
linux·服务器·网络·c++·网络协议
fancy1661661 小时前
搜索二维矩阵 II
c++·算法·矩阵
freyazzr1 小时前
Leetcode刷题 | Day63_图论08_拓扑排序
数据结构·c++·算法·leetcode·图论
敖云岚1 小时前
【Linux】基于虚拟机实现网络的管理
linux·服务器·网络
顾子茵1 小时前
c++从入门到精通(四)--动态内存,模板与泛型编程
java·开发语言·c++
luck_me51 小时前
如何远程执行脚本不留痕迹
linux·运维·服务器
邹诗钰-电子信息工程1 小时前
嵌入式自学第二十二天(5.15)
c语言
-SGlow-1 小时前
Linux相关概念和易错知识点(40)(HTML资源交互、网页管理、搜索引擎)
linux·运维·服务器·网络·html·交互
默心1 小时前
centos7部署mysql5.7
linux·运维·mysql·centos
ai.Neo1 小时前
牛客网NC22015:最大值和最小值
数据结构·c++·算法