home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / gcc / ixemulsrc.lha / ixemul / library / kprintf.h < prev    next >
C/C++ Source or Header  |  1996-12-11  |  1KB  |  42 lines

  1. /*  Support stuff for doing low level debugging of the library and/or
  2.  *  runtime startup code using KPrintF.
  3.  *
  4.  *  Compile with CFLAGS="-O2 -DDEBUG_VERSION" to get debugging version.
  5.  *
  6.  *  FIXME: For some reason the -O2 is required, otherwise the system
  7.  *  crashes.
  8.  */
  9.  
  10. /*
  11.  *  Use as:    KPRINTF (("foo = %s\n", bar));
  12.  *  Prints:    /mysource/project/bell.c:45: foo = bell
  13.  */
  14.  
  15. #ifndef __KPRINTF_H__
  16. #define __KPRINTF_H__
  17.  
  18. #ifdef DEBUG_VERSION
  19.  
  20. #define KPRINTF_WHERE        do { KPrintF ("%s:%ld: ", __FILE__, __LINE__); } while (0)
  21. #define KPRINTF_ARGS(a)        do { KPrintF a; } while (0)
  22. #define KPRINTF(a)        do { KPRINTF_WHERE; KPRINTF_ARGS(a); } while (0)
  23. #define KPRINTF_DISABLED(a)    do { Disable (); KPRINTF (a); Enable (); } while (0)
  24.  
  25. #define KPRINTF_ARGV(name,argv) \
  26.   do { int argi; \
  27.     for (argi = 0; (argv)[argi] != NULL; argi++) \
  28.       KPRINTF (("%s[%ld] = [%s]\n", (name), argi, (argv)[argi])); \
  29.   } while (0)
  30.  
  31. #else    /* not DEBUG_VERSION */
  32.  
  33. #define KPRINTF_WHERE            /* Expands to nothing */
  34. #define KPRINTF_ARGS(a)            /* Expands to nothing */
  35. #define KPRINTF(a)            /* Expands to nothing */
  36. #define KPRINTF_DISABLED(a)        /* Expands to nothing */
  37. #define KPRINTF_ARGV(name,argv)        /* Expands to nothing */
  38.  
  39. #endif    /* DEBUG_VERSION */
  40.  
  41. #endif
  42.