home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 (Developer) / NS_dev_3.2.iso / NextDeveloper / Headers / bsd / c.h < prev    next >
C/C++ Source or Header  |  1992-04-10  |  2KB  |  62 lines

  1. /*
  2.  * Standard C macros
  3.  *
  4.  **********************************************************************
  5.  * HISTORY
  6.  * 02-Feb-86  Glenn Marcy (gm0w) at Carnegie-Mellon University
  7.  *    Added check to allow multiple or recursive inclusion of this
  8.  *    file.  Added bool enum from machine/types.h for regular users
  9.  *    that want a real boolean type.
  10.  *
  11.  * 29-Dec-85  Glenn Marcy (gm0w) at Carnegie-Mellon University
  12.  *    Also change spacing of MAX and MIN to coincide with that of
  13.  *    sys/param.h.
  14.  *
  15.  * 19-Nov-85  Glenn Marcy (gm0w) at Carnegie-Mellon University
  16.  *    Changed the number of tabs between TRUE, FALSE and their
  17.  *    respective values to match those in sys/types.h.
  18.  *
  19.  * 17-Dec-84  Glenn Marcy (gm0w) at Carnegie-Mellon University
  20.  *    Only define TRUE and FALSE if not defined.  Added caseE macro
  21.  *    for using enumerated types in switch statements.
  22.  *
  23.  * 23-Apr-81  Mike Accetta (mja) at Carnegie-Mellon University
  24.  *    Added "sizeofS" and "sizeofA" macros which expand to the size
  25.  *    of a string constant and array respectively.
  26.  *
  27.  **********************************************************************
  28.  */
  29.  
  30. #ifndef    _C_INCLUDE_
  31. #define    _C_INCLUDE_
  32.  
  33. #ifndef ABS
  34. #define ABS(x) ((x)>=0?(x):-(x))
  35. #endif ABS
  36. #ifndef MIN
  37. #define    MIN(a,b) (((a)<(b))?(a):(b))
  38. #endif MIN
  39. #ifndef MAX
  40. #define    MAX(a,b) (((a)>(b))?(a):(b))
  41. #endif MAX
  42.  
  43. #ifndef    FALSE
  44. #define FALSE    0
  45. #endif    FALSE
  46. #ifndef    TRUE
  47. #define TRUE    1
  48. #endif    TRUE
  49.  
  50. #define    CERROR        (-1)
  51.  
  52. #ifndef    bool
  53. typedef enum    { false = 0, true = 1 } bool;
  54. #endif    bool
  55.  
  56. #define    sizeofS(string)    (sizeof(string) - 1)
  57. #define sizeofA(array)    (sizeof(array)/sizeof(array[0]))
  58.  
  59. #define caseE(enum_type)    case (int)(enum_type)
  60.  
  61. #endif    _C_INCLUDE_
  62.