zoukankan      html  css  js  c++  java
  • 自定义debug函数

    简单的DEBUG宏

    /********************** debug.h *************************/
    #ifndef  _DEBUG_H_
    #define  _DEBUG_H_
    
    #define DEBUG
    #ifdef DEBUG
    //#define  TOY_DEBUG(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
    #define  TOY_DEBUG(format, ...) printf (format, ## __VA_ARGS__)
    #else
    #define  TOY_DEBUG(format, ...)
    #endif
    
    #endif //_DEBUG_H_

    /********************main.c*****************************/
    int main (void) {         debug_printf("hello\n");         debug_printf("hello, %d\n", 10);
            return 0; }
    /* 定义级别的DEBUG函数
    */
    #include <stdio.h> #include <stdlib.h> #ifdef MY_DEBUG #include <stdarg.h> int debug_level; void debug(int level, const char *fmt, ...) { if( level <= debug_level ) { va_list ap; va_start(ap, fmt); vprintf(fmt, ap); va_end(ap); } } #else void debug(int level, const char *fmt, ...) { } #endif
  • 相关阅读:
    既然选择了远方,就只顾风雨兼程!
    slots
    面向对象
    模块和作用域
    偏函数
    python中decorator
    返回函数
    filter, sort
    map/reduce
    开发步骤
  • 原文地址:https://www.cnblogs.com/cfox/p/2751054.html
Copyright © 2011-2022 走看看