home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / desklib / !DeskLib / h / WAssert < prev    next >
Encoding:
Text File  |  1994-04-10  |  2.0 KB  |  55 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    WAssert.h
  12.     Author:  Copyright © 1993 Mark H. Wilkinson
  13.     Version: 1.00 (05 Sep 1993)
  14.     Purpose: Wimp version of ANSI assert() system, based on RISCOS_Lib
  15.              version presented in Archive magazine 6.12.53 by Remo Biagioni.
  16. */
  17.  
  18. /*  NOTES
  19.  *  Assertions are used for debugging programs. They should be placed liberally
  20.  *  throughout your code to check that certain conditions are met during
  21.  *  development, and then the program re-compiled without them for final
  22.  *  release.
  23.  *
  24.  *  e.g. if you have a function that expects a parameter which must be positive
  25.  *  then it should include a line like:
  26.  *    assert(parameter >= 0, "Parameter is negative!");
  27.  *
  28.  *  If 'parameter' is not >= 0 then a wimp error box will report the fact,
  29.  *  indicating where in your source the assertion failed.
  30.  *
  31.  *  To use assertions you must compile your code with _DEBUG defined
  32.  *  (i.e. run the compiler with the extra switch -D_DEBUG)
  33.  *
  34.  *  To build a release version of your program without the assertions in it
  35.  *  (which will reduce the size of the program and increase execution speed)
  36.  *  simply compile it ensuring that _DEBUG is not defined.
  37.  */
  38.  
  39.  
  40. #ifndef __dl_wassert_h
  41. #  define __dl_wassert_h
  42. extern void __wassert(char *);
  43. #else
  44. #  undef assert
  45. #endif
  46.  
  47. #ifdef _DEBUG
  48. #  define assert(ignore) ((void)0)
  49. #else
  50. #  define __SR(x) __VL(x)
  51. #  define __VL(x) #x
  52. #  define assert(e) ((e) ? (void)0 : _wassert("Assertion " #e " failed at line " __SR(__LINE__) " of file " __FILE__))
  53. #endif
  54.  
  55.