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);
相关推荐
载数而行5205 小时前
QT的五类布局
c++·qt·学习
故事和你915 小时前
sdut-程序设计基础Ⅰ-实验五一维数组(8-13)
开发语言·数据结构·c++·算法·蓝桥杯·图论·类和对象
载数而行5205 小时前
QT的QString类
c++·qt·学习
芯联智造6 小时前
【stm32简单外设篇】- WS2812单线地址式 RGB 灯带
c语言·stm32·单片机·嵌入式硬件
bu_shuo6 小时前
Visual C++2010学习版(全国计算机等级二级考试版)安装记录
c++·cpp·visual c++·计算机二级
V__KING__8 小时前
systemd-remount-fs,fstab之间的渊源
linux·服务器·网络
酿情师8 小时前
Windows Subsystem for Linux (WSL, Ubuntu)安装教程(详细)
linux·windows·ubuntu
Titan20249 小时前
Linux环境变量个人笔记
linux·服务器·c++
青柠代码录9 小时前
【Linux】路径区分:testdir、testdir/、testdir/*
linux·运维·服务器
7yewh9 小时前
jetson_yolo_deployment 02_linux_dev_skills
linux·python·嵌入式硬件·yolo·嵌入式