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
  • 相关阅读:
    C语言I博客作业08
    作业7
    作业6
    作业5
    作业--4
    java基础学习--I/O流
    刷题记录--[CISCN2019 华北赛区 Day2 Web1]Hack World
    ADB测试Android真机
    sqli-labs通关笔记
    Tensorflow入门
  • 原文地址:https://www.cnblogs.com/cfox/p/2751054.html
Copyright © 2011-2022 走看看