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);
相关推荐
2301_795167202 小时前
玩转Rust高级应用 如何避免对空指针做“解引用”操作,在C/C++ 里面就是未定义行为
c语言·c++·rust
你想考研啊2 小时前
linux安装jdk和tomcat和并自启动
java·linux·tomcat
习惯就好zz4 小时前
WSL2 安装Ubuntu卡在安装进度0%无响应问题解决
linux·windows·ubuntu·wsl·wsl2
躲猫猫的喵喵5 小时前
Ubuntu2204降内核版本
linux·运维·服务器·ubuntu
昌sit!5 小时前
Linux系统性基础学习笔记
linux·笔记·学习
zdslovezy5 小时前
CentOS 系统升级 OpenSSH 和 OpenSSL 的完整方案
linux·运维·centos
HIT_Weston6 小时前
18、【Ubuntu】【远程开发】技术方案分析:私网ip掩码
linux·tcp/ip·ubuntu
cccccc语言我来了6 小时前
(Linux (6):从包管理到工具探索,构建系统操作基础认知)
linux·运维·服务器
不染尘.7 小时前
2025_11_7_刷题
开发语言·c++·vscode·算法
ben9518chen7 小时前
嵌入式Linux C语言程序设计九
linux·c语言