【整理】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. ...
随机推荐
- 用大O记号法测量算法的效率(Algorithm efficiency Asymptotic notation Big O notation)
为什么要了解算法的效率? 一般来说,编程就是把各种已知的算法代入到自己的代码当中,以此来解决问题.因此,了解各种算法的效率对于我们选择一个合适的算法有很大帮助. 算法的效率由什么确定? 从算法分析的理 ...
- windows环境pip安装时一直报错Could not fetch URL https://pypi.org/simple/xrld/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url:
最近项目不忙了~~有开始专研的python大业,上来想用pip安装一个第三方的库,就一直报错: Could not fetch URL https://pypi.org/simple/xrld/: T ...
- 【BZOJ3379】【USACO2004】交作业 区间DP
题目描述 数轴上有\(n\)个点,你要从位置\(0\)去位置\(B\),你每秒钟可以移动\(1\)单位.还有\(m\)个限制,每个限制\((x,y)\)表示你要在第\(t\)秒之后(可以是第\(t\) ...
- linux下执行sh脚本,提示Command not found解决办法
1.确保用户对文件有读写及执行权限 oracle@linux-106:~/RMAN/bin> chmod a+x test.sh 2.然后修改文件格式(如果是从winodws搬过来的会显示dos ...
- 中断 LET′S TRY“嵌入式编程”: 5 of 6
中断 LET′S TRY“嵌入式编程”: 5 of 6 本连载讲解作为嵌入式系统开发技术人员所必需具备的单片机的基础知识.本期为最后一期,将为大家介绍在单片机控制系统中不可缺少的 处理方式--“中断” ...
- 前端基础-- HTML
HTML知识 HTML介绍 Web服务本质 浏览器发请求 --> HTTP协议 --> 服务端接收请求 --> 服务端返回响应 --> 服务端把HTML文件内容发给浏览器 -- ...
- 牛客小白月赛12J(序列自动机)
题目链接:https://ac.nowcoder.com/acm/contest/392/J 题目大意:给一个字符串s,然后在给出n个其他的字符串,判断每个字符串是否为s的子序列. 例: 输入: no ...
- Linux:文件系统层次结构标准(Filesystem Hierarchy Standard)
Linux FHS_2.3标准文档:http://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.pdf
- Arch Linux下韩文重叠显示
解决方法 sudo pacman -S wqy-microhei-kr-patched
- A1013. Battle Over Cities
It is vitally important to have all the cities connected by highways in a war. If a city is occupied ...