#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. web页面简单布局的修改,测试中的应用

    在做功能测试的时候发现,界面显示不美观,觉得登录按钮应向上移动,那么如何移动呢? 很简单:使用开发者工具找到这个按钮所在的div,修改其中的属性值,top值减小,即可实现按钮向上移动,具体可以看效果

  2. 【XSY1098】第k小 可持久化trie

    题目描述 给你一个长度为\(n\)数列\(a\),有\(m\)次操作: \(1~x\):把所有数异或\(x\) \(2~x\):把所有数与\(x\) \(3~x\):把所有数或\(x\) \(4~l~ ...

  3. zabbix 自动发现端口并添加监控设置

    自动发现端口并添加监控设置UserParameter=net.listen.discovery,sudo /etc/zabbix/scripts/discovery_listport.sh #!/bi ...

  4. Codeforces Round #463 F. Escape Through Leaf (李超线段树合并)

    听说正解是啥 set启发式合并+维护凸包+二分 根本不会啊 , 只会 李超线段树合并 啦 ... 题意 给你一颗有 \(n\) 个点的树 , 每个节点有两个权值 \(a_i, b_i\) . 从 \( ...

  5. 每天一个linux命令(1):wc命令

    Linux系统中的wc(Word Count)命令的功能为统计指定文件中的字节数.字数.行数,并将统计结果显示输出. 1.命令格式: wc [选项]文件... 2.命令功能: 统计指定文件中的字节数. ...

  6. 汽车控制器LIMPHOME电路设计

    摘要:本文介绍汽车控制器上常用的3种LIMPHOME电路设计方法,用于在单片机复位重启期间仍能保证外部输出正确性,确保行车安全.    在电子电气领域,单片机使用非常广泛,单片机的复位重启是设计时必须 ...

  7. HDU5985 Lucky Coins 概率dp

    题意:给你N种硬币,每种硬币有Si个,有Pi 概率朝上,每次抛所有硬币抛起,所有反面的拿掉,问每种硬币成为最后的lucky硬币的概率. 题解:都知道是概率dp,但是模拟赛时思路非常模糊,很纠结,dp[ ...

  8. 百度地图API,展示地图和添加控件

    1.申请百度账号和AK 点我申请 2.准备页面 根据HTML标准,每一份HTML文档都应该声明正确的文档类型,我们建议您使用最新的符合HTML5规范的文档声明: <!DOCTYPE html&g ...

  9. SRM 605 div 2 T3

    #include <bits/stdc++.h> #define Mo 1000000007 #define MAXN 50 #define MAXK 10 using namespace ...

  10. BZOJ2940 条纹

    条纹游戏是一个双人的游戏.所需要的物品有一个棋盘以及三种颜色的长方形条纹,这三种颜色分别是红色.绿色和蓝色.所有的红色条纹的尺寸是c*1,所有的绿色条纹的尺寸是z*1,所有的蓝色条纹的尺寸是n*1,这 ...