home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / me34src.zip / me3 / util / const.h < prev    next >
C/C++ Source or Header  |  1995-01-14  |  2KB  |  49 lines

  1. /* const.h : constants, typedefs and macros that I use
  2.  * C Durland    Public Domain
  3.  */
  4.  
  5. #ifndef __CONST_H_INCLUDED
  6. #define __CONST_H_INCLUDED
  7.  
  8. /* ******************************************************************** */
  9. /* **************************** Constants ***************************** */
  10. /* ******************************************************************** */
  11.  
  12. #ifndef TRUE
  13. #define TRUE  1
  14. #define FALSE 0
  15. #endif
  16.  
  17. #ifndef NULL
  18. #define NULL 0
  19. #endif
  20.  
  21. /* ******************************************************************** */
  22. /* ***************************** Typedefs ***************************** */
  23. /* ******************************************************************** */
  24.  
  25. typedef int  (*pfi)();        /* pointer to function returning int */
  26. typedef void (*pfv)();        /* pointer to function returning void */
  27.  
  28. /* ******************************************************************** */
  29. /* ****************************** Macros ****************************** */
  30. /* ******************************************************************** */
  31.  
  32.     /* size of static array */
  33. #define NITEMS(array) (sizeof(array)/sizeof(array[0]))
  34.  
  35.     /* increment a type (usually pointer) by n bytes */
  36. #define INC_TYPE(type,ptr,n) (type)((char *)ptr +n)
  37.  
  38.     /* Calculate the number of decimal digits per integer type (including
  39.      *   the sign).  Type size is sizeof(type) - bytes.
  40.      * Formula:  round_up(Log10(bytes)) + 1 (for sign)
  41.      * Approximation: 2*bytes + (bytes + 1)/2 + 1
  42.      *   This is good for (at least) 32 bytes - it may add a digit or two
  43.      *     above 6 bytes.
  44.      */
  45. #define DIGITS_PER_INT(bytes) ((bytes)*2 + ((bytes) + 1)/2 + 1)
  46.  
  47.  
  48. #endif    /* __CONST_H_INCLUDED */
  49.