#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的更多相关文章

  1. Linux下Tomcat启动设置debug模式启动

    原文: https://blog.csdn.net/li295214001/article/details/42077247 https://blog.csdn.net/jackie_xiaonan/ ...

  2. Linux下的两个经典宏定义 转

    http://www.linuxidc.com/Linux/2016-08/134481.htm http://www.linuxidc.com/Linux/2013-01/78003.htm htt ...

  3. Linux下的两个经典宏定义【转】

    转自:http://www.linuxidc.com/Linux/2015-07/120014.htm 本文首先介绍Linux下的经典宏定义,感受极客的智慧,然后根据该经典定义为下篇文章作铺垫. of ...

  4. 笔记整理——Linux下C语言正则表达式

    Linux下C语言正则表达式使用详解 - Google Chrome (2013/5/2 16:40:37) Linux下C语言正则表达式使用详解 2012年6月6日Neal627 views发表评论 ...

  5. 归纳整理Linux下C语言常用的库函数----文件操作

    在没有IDE的时候,记住一些常用的库函数的函数名.参数.基本用法及注意事项是很有必要的. 参照Linux_C_HS.chm的目录,我大致将常用的函数分为一下几类: 1. 内存及字符串控制及操作 2. ...

  6. 整理 Linux下列出目录内容的命令

    在 Linux 中,有非常多的命令可以让我们用来执行各种各样的任务.当我们想要像使用文件浏览器一样列出一个目录下的内容时,大家第一时间想到的是 ls 命令.但只有 ls 命令能实现这个目的吗?显然不是 ...

  7. C语言:类似linux内核的分等级DEBUG宏(打印宏)

    总结几种log打印printf函数的宏定义 http://blog.chinaunix.net/uid-20564848-id-73402.html #include <stdio.h> ...

  8. 归纳整理Linux下C语言常用的库函数----时间日期数学及算法

    在没有IDE的时候,记住一些常用的库函数的函数名.参数.基本用法及注意事项是很有必要的. 参照Linux_C_HS.chm的目录,我大致将常用的函数分为一下几类: 1. 内存及字符串控制及操作 2. ...

  9. 归纳整理Linux下C语言常用的库函数----内存及字符串控制及操作

    在没有IDE的时候,记住一些常用的库函数的函数名.参数.基本用法及注意事项是很有必要的. 参照Linux_C_HS.chm的目录,我大致将常用的函数分为一下几类: 1. 内存及字符串控制及操作 2. ...

随机推荐

  1. 安装PHP 类库PEAR

    PHP扩展与应用库常识 当php项目里没有pear时: 单独安装解决方案 下载下面连接的文件至go-pear.phar.http://pear.php.net/go-pear.phar该文件最好放到P ...

  2. git同步远程已删除的分支和删除本地多余的分支

    使用 git branch -a 可以查看本地分支和远程分支情况 但远程分支(红色部分)删除后,发现本地并没有同步过来. 一. 同步本地的远程分支 查看本地分支和追踪情况: git remote sh ...

  3. 怎么让 Lua 5.3.4 支持中文变量名和中文函数名

    1. 在官网下载最新版Lua源码 Lua :Download 2. 解压后进入目录,找到/src/llex.c,打开修改 找到如下内容 修改为下面代码,并保存. default: { if (lisl ...

  4. 【CF865D】Buy Low Sell High(贪心)

    [CF865D]Buy Low Sell High(贪心) 题面 洛谷 CF 题解 首先有一个\(O(n^2)\)的\(dp\)很显然,设\(f[i][j]\)表示前\(i\)天手中还有\(j\)股股 ...

  5. centos7下安装部署mongodb集群(副本集模式)

    环境需求:Mongodb集群有三种模式:  Replica Set, Sharding,Master-Slaver.  这里部署的是Replica Set模式. 测试环境: 这里副本集(Replica ...

  6. 牛客练习赛43 Tachibana Kanade Loves Probability(快速幂)

    链接:https://ac.nowcoder.com/acm/contest/548/B来源:牛客网 题目描述 立华奏在学习初中数学的时候遇到了这样一道大水题: “设箱子内有 n 个球,其中给 m 个 ...

  7. JSP、EL、JSTL

    JSP(Java Server Pages) 什么是JSP Java Server Pages(Java服务器端的页面) 使用JSP:SP = HTML + Java代码 + JSP自身的东西.执行J ...

  8. Nginx实践篇(2)- Nginx作为静态资源web服务 - 控制浏览器缓存、防盗链

    一.控制浏览器缓存 1. 浏览器缓存简介 浏览器缓存遵循HTTP协议定义的缓存机制(如:Expires;Cache-control等). 当浏览器无缓存时,请求响应流程 当浏览器有缓存时,请求响应流程 ...

  9. P1886 P2216 单调队列模板

    何为单调队列? 单调队列是一个队列(废话) 而且必须同时满足下标单调和值单调两个单调特性. 跟优先队列不同,优先队列直接使用堆(heap)来实现,如何删去特定下标元素?不明. 本人喜欢用单调队列存下标 ...

  10. '新', '泽' - ImageMagick - UTF-8非最短形式及编码安全问题

    最近偶然发现,把软件放到 [新建文件夹]  中,ImageMagick 竟无法正常的加载图片了. 我去!什么情况? 抛出的错误是找不到相关的dll,软件中已对中文进行了utf-8编码,这几年来一直没发 ...