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);
相关推荐
Murphy_lx8 分钟前
Lambda表达式
开发语言·c++
saynaihe10 分钟前
proxmox8升级到proxmox9
linux·运维·服务器
yangpipi-16 分钟前
C++并发编程-23. 线程间切分任务的方法
开发语言·c++
Orchestrator_me23 分钟前
CentOS交换区处理
linux·运维·centos
zru_960224 分钟前
centos 系统如何安装open jdk 8
java·linux·centos
FLS16826 分钟前
VMwaer虚拟机安装完Centos后无法联网问题
linux·运维·centos
OctopusMonster27 分钟前
centos下gdb调试python的core文件
linux·运维·centos
楼田莉子1 小时前
C++算法专题学习——分治
数据结构·c++·学习·算法·leetcode·排序算法
snowfoootball2 小时前
(自用)Linux 常用命令自查文档
linux·运维·服务器
ulias2122 小时前
各种背包问题简述
数据结构·c++·算法·动态规划