Skip to content

Instantly share code, notes, and snippets.

@itrobotics
Created September 9, 2022 02:22

Revisions

  1. itrobotics created this gist Sep 9, 2022.
    26 changes: 26 additions & 0 deletions debug.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@

    #include <stdio.h>

    //#define DEBUG 3

    #ifdef DEBUG
    #define debug(fmt,args...) printf (fmt ,##args)
    #define debugX(level,fmt,args...) if (DEBUG>=level) printf(fmt,##args);
    #else
    #define debug(fmt,args...)
    #define debugX(level,fmt,args...)
    #endif /* DEBUG */


    int main()
    {

    int n=10;
    debug("bug found!!\n");
    debug("n is %d\n",n);

    debugX(3,"bug found!!\n");
    debugX(4,"n is %d\n",n);

    return 0;
    }