• 自定义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
  • 相关阅读:
    python sys 模块
    python os 模块
    JS Dictionary
    JS Array
    JS String
    JS面向对象
    WPF中INotifyPropertyChanged用法与数据绑定
    JS的函数
    JS类型转换
    JS变量的作用域
  • 原文地址:https://www.cnblogs.com/cfox/p/2751054.html
Copyright © 2020-2023  润新知