【整理】Linux 下 自己使用的 debug宏 printf
#ifdef __DEBUG_PRINTF__
/*
*
* Some Debug printf kit for devlopment
*
* Date : 2019.03.04
*
* Editor : SCHIPS
*
*/ #include <stdio.h>
/* Debug with file name and line. */
#define DEBUG(format,...) printf(""format"\n", ##__VA_ARGS__ )
#define DEBUG_RED(format,...) printf("\033[30m\033[31m"format"\033[0m\n", ##__VA_ARGS__)
#define DEBUG_GREEN(format,...) printf("\033[30m\033[32m"format"\033[0m\n", ##__VA_ARGS__)
#define DEBUG_YELLOW(format,...) printf("\033[30m\033[33m"format"\033[0m\n", ##__VA_ARGS__)
#define DEBUG_PURP(format,...) printf("\033[30m\033[35m"format"\033[0m\n", ##__VA_ARGS__)
#define DEBUG_BLUE(format,...) printf("\033[30m\033[36m"format"\033[0m\n", ##__VA_ARGS__) /* Debug printf infomration with color. */
#define DEBUG_FL(format,...) printf("["__FILE__"](%05d) - %s]\n "format"\n", __LINE__, ##__VA_ARGS__ , __FUNCTION__) #define DEBUG_FLR(format,...) printf("\033[30m\033[31m["__FILE__"](%05d) - %s]\n\033[0m "format"\n", __LINE__, __FUNCTION__,##__VA_ARGS__)
#define DEBUG_FLG(format,...) printf("\033[30m\033[32m["__FILE__"](%05d) - %s]\n\033[0m "format"\n", __LINE__, __FUNCTION__,##__VA_ARGS__)
#define DEBUG_FLY(format,...) printf("\033[30m\033[33m["__FILE__"](%05d) - %s]\n\033[0m "format"\n", __LINE__, __FUNCTION__,##__VA_ARGS__)
#define DEBUG_FLP(format,...) printf("\033[30m\033[35m["__FILE__"](%05d) - %s]\n\033[0m "format"\n", __LINE__, __FUNCTION__,##__VA_ARGS__)
#define DEBUG_FLB(format,...) printf("\033[30m\033[36m["__FILE__"](%05d) - %s]\n\033[0m "format"\n", __LINE__, __FUNCTION__,##__VA_ARGS__) #define DEBUG_SFL(format,...) printf("["__FILE__"](%05d) - %s] "format"\n", __LINE__, ##__VA_ARGS__ , __FUNCTION__)
#define DEBUG_SFLR(format,...) printf("\033[30m\033[31m["__FILE__"](%05d) - %s]\033[0m "format"\n", __LINE__, __FUNCTION__,##__VA_ARGS__)
#define DEBUG_SFLG(format,...) printf("\033[30m\033[32m["__FILE__"](%05d) - %s]\033[0m "format"\n", __LINE__, __FUNCTION__,##__VA_ARGS__)
#define DEBUG_SFLY(format,...) printf("\033[30m\033[33m["__FILE__"](%05d) - %s]\033[0m "format"\n", __LINE__, __FUNCTION__,##__VA_ARGS__)
#define DEBUG_SFLP(format,...) printf("\033[30m\033[35m["__FILE__"](%05d) - %s]\033[0m "format"\n", __LINE__, __FUNCTION__,##__VA_ARGS__)
#define DEBUG_SFLB(format,...) printf("\033[30m\033[36m["__FILE__"](%05d) - %s]\033[0m "format"\n", __LINE__, __FUNCTION__,##__VA_ARGS__) #define SC_CLEAR() printf("\033[2J") #if 0
/* Another format to Print (Too ugly to me to use.)*/
#define DEBUGA(fmt,args...) printf("[%s(%05d) - %s]\n "#fmt"\n", __FILE__, __LINE__, __FUNCTION__, ##args)
#endif #else
#define DEBUG(format,...)
#define DEBUG_RED(format,...)
#define DEBUG_GREEN(format,...)
#define DEBUG_YELLOW(format,...)
#define DEBUG_PURP(format,...)
#define DEBUG_BLUE(format,...) #define DEBUG_FL(format,...)
#define DEBUG_FLR(format,...)
#define DEBUG_FLG(format,...)
#define DEBUG_FLY(format,...)
#define DEBUG_FLP(format,...)
#define DEBUG_FLB(format,...) #define DEBUG_SFL(format,...)
#define DEBUG_SFLR(format,...)
#define DEBUG_SFLG(format,...)
#define DEBUG_SFLY(format,...)
#define DEBUG_SFLP(format,...)
#define DEBUG_SFLB(format,...)
#define SC_CLEAR(format,...)
#endif
debug.h
#include <stdio.h> #if 1 // To turn on/off Debug printf;
#define __DEBUG_PRINTF__ #endif #include "debug.h" void fun1(void)
{
DEBUG("DEBUG");
DEBUG_RED("RED.");
DEBUG_GREEN("GREEN.");
DEBUG_YELLOW("YELLOW.");
return ;
} void fun2(char* buff)
{
int i = ;
DEBUG_FL("fun2");
DEBUG_FLB("i = %d", i);
DEBUG_FLR("buff = %s", buff);
DEBUG_FLP("buff = %s", buff);
return ;
} void fun3(char* buff, int i)
{
DEBUG_SFL("fun3");
DEBUG_SFLB("i = %d", i);
DEBUG_SFLR("buff = %s", buff);
DEBUG_SFLP("buff = %s", buff);
return ;
}
int main(void)
{
SC_CLEAR(); fun1(); printf("---------\n"); fun2("fun 2"); printf("---------\n"); fun3("fun3",); return ;
}
demo_main.c

【整理】Linux 下 自己使用的 debug宏 printf的更多相关文章
- Linux下Tomcat启动设置debug模式启动
原文: https://blog.csdn.net/li295214001/article/details/42077247 https://blog.csdn.net/jackie_xiaonan/ ...
- Linux下的两个经典宏定义 转
http://www.linuxidc.com/Linux/2016-08/134481.htm http://www.linuxidc.com/Linux/2013-01/78003.htm htt ...
- Linux下的两个经典宏定义【转】
转自:http://www.linuxidc.com/Linux/2015-07/120014.htm 本文首先介绍Linux下的经典宏定义,感受极客的智慧,然后根据该经典定义为下篇文章作铺垫. of ...
- 笔记整理——Linux下C语言正则表达式
Linux下C语言正则表达式使用详解 - Google Chrome (2013/5/2 16:40:37) Linux下C语言正则表达式使用详解 2012年6月6日Neal627 views发表评论 ...
- 归纳整理Linux下C语言常用的库函数----文件操作
在没有IDE的时候,记住一些常用的库函数的函数名.参数.基本用法及注意事项是很有必要的. 参照Linux_C_HS.chm的目录,我大致将常用的函数分为一下几类: 1. 内存及字符串控制及操作 2. ...
- 整理 Linux下列出目录内容的命令
在 Linux 中,有非常多的命令可以让我们用来执行各种各样的任务.当我们想要像使用文件浏览器一样列出一个目录下的内容时,大家第一时间想到的是 ls 命令.但只有 ls 命令能实现这个目的吗?显然不是 ...
- C语言:类似linux内核的分等级DEBUG宏(打印宏)
总结几种log打印printf函数的宏定义 http://blog.chinaunix.net/uid-20564848-id-73402.html #include <stdio.h> ...
- 归纳整理Linux下C语言常用的库函数----时间日期数学及算法
在没有IDE的时候,记住一些常用的库函数的函数名.参数.基本用法及注意事项是很有必要的. 参照Linux_C_HS.chm的目录,我大致将常用的函数分为一下几类: 1. 内存及字符串控制及操作 2. ...
- 归纳整理Linux下C语言常用的库函数----内存及字符串控制及操作
在没有IDE的时候,记住一些常用的库函数的函数名.参数.基本用法及注意事项是很有必要的. 参照Linux_C_HS.chm的目录,我大致将常用的函数分为一下几类: 1. 内存及字符串控制及操作 2. ...
随机推荐
- bzoj 1452: [JSOI2009]Count (二维树状数组)
链接:https://www.lydsy.com/JudgeOnline/problem.php?id=1452 思路: 对每个颜色开一个二维树状数组维护就好了 实现代码: #include<b ...
- Nowcoder | [题解-N189]牛客OI赛制测试赛3
这场说实话确实水(逃*1),表示差一点就AK了(逃*2),然而被卡两个特判的我\(ssfd\)...\(qwq\) 表示这是第一次发整场比赛的题解...还请各位大佬原谅我太蒻写的垃圾啊\(qwq\). ...
- ⌈洛谷5058⌋⌈ZJOI2004⌋嗅探器【Tarjan】
题目连接 [洛谷传送门] [LOJ传送门] 题目描述 某军搞信息对抗实战演习,红军成功地侵入了蓝军的内部网络,蓝军共有两个信息中心,红军计划在某台中间服务器上安装一个嗅探器,从而能够侦听到两个信息中心 ...
- 【php】 php获取文件路径中的文件名和文件后缀方法
获取文件名 $file = realpath(__DIR__.'/images/common/../addBtn.png'); 方法一 $file = realpath(__DIR__.'/image ...
- Java,mysql String与date类型转换
String 与 date类型转换 字符串转换成日期类型: SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");//小写 ...
- 为什么每次app访问服务器都建立新连接 导致服务器大量连接疯涨
运维发现服务器有大量连接不释放,而且每次app访问都会建立新连接. netstat -antlp |grep ESTAB|grep 8080|wc -l (访问服务器8080端口的已建立的连接数 ...
- [bzoj1692][队列变换]
题目链接 思路 首先肯定想到贪心,从队尾和队首取更小的那个. 但是如果遇到队尾和队首一样大的情况呢,总不能再挨个往前比较.所以就把整个字符串倒过来再挂到现在字符串的后面,也就是把当前字符串对称过去.然 ...
- jquery基本语法(一)
https://www.cnblogs.com/haiyan123/p/7657151.html 一.jQuery基础1.为什么要用jquery? 写起来简单,省事,开发效率高,兼容性好2.什么 ...
- Linux安装 火速入门
一.基本简介 Linux是一套免费使用和自由传播的类Unix操作系统,是一个基于POSIX和UNIX的多用户.多任务.支持多线程和多CPU的操作系统. Linux能运行主要的UNIX工具软件.应用程序 ...
- bs4抓取糗事百科
抓取糗事百科内容及评论,不包含图片信息.user-agent填入浏览器的即可.user-agent对应的value,360极速浏览器的话,可以在地址栏输入about:version,回车,用户代理后面 ...