home *** CD-ROM | disk | FTP | other *** search
/ PC World 2000 January / PCWorld_2000-01_cd.bin / Software / Servis / Devc / _SETUP.4 / Group3 / limits.h < prev    next >
C/C++ Source or Header  |  1998-12-24  |  2KB  |  108 lines

  1. /* 
  2.  * limits.h
  3.  *
  4.  * Defines constants for the sizes of integral types.
  5.  *
  6.  * NOTE: GCC should supply a version of this header and it should be safe to
  7.  *       use that version instead of this one (maybe safer).
  8.  *
  9.  * This file is part of the Mingw32 package.
  10.  *
  11.  * Contributors:
  12.  *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
  13.  *
  14.  *  THIS SOFTWARE IS NOT COPYRIGHTED
  15.  *
  16.  *  This source code is offered for use in the public domain. You may
  17.  *  use, modify or distribute it freely.
  18.  *
  19.  *  This code is distributed in the hope that it will be useful but
  20.  *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
  21.  *  DISCLAMED. This includes but is not limited to warranties of
  22.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  23.  *
  24.  * $Revision: 2.1 $
  25.  * $Author: colin $
  26.  * $Date: 1997/11/24 06:19:59 $
  27.  *
  28.  */
  29.  
  30. #ifndef _LIMITS_H_
  31. #define _LIMITS_H_
  32.  
  33. /*
  34.  * File system limits
  35.  *
  36.  * TODO: NAME_MAX and OPEN_MAX are file system limits or not? Are they the
  37.  *       same as FILENAME_MAX and FOPEN_MAX from stdio.h?
  38.  * NOTE: Apparently the actual size of PATH_MAX is 260, but a space is
  39.  *       required for the NUL. TODO: Test?
  40.  */
  41. #define PATH_MAX    (259)
  42.  
  43. /*
  44.  * Characteristics of the char data type.
  45.  *
  46.  * TODO: Is MB_LEN_MAX correct?
  47.  */
  48. #define CHAR_BIT    8
  49. #define MB_LEN_MAX    2
  50.  
  51. #define SCHAR_MIN    (-128)
  52. #define SCHAR_MAX    127
  53.  
  54. #define UCHAR_MAX    255
  55.  
  56. /* TODO: Is this safe? I think it might just be testing the preprocessor,
  57.  *       not the compiler itself... */
  58. #if    ('\x80' < 0)
  59. #define CHAR_MIN    SCHAR_MIN
  60. #define CHAR_MAX    SCHAR_MAX
  61. #else
  62. #define CHAR_MIN    0
  63. #define CHAR_MAX    UCHAR_MAX
  64. #endif
  65.  
  66. /*
  67.  * Maximum and minimum values for ints.
  68.  */
  69. #define INT_MAX        2147483647
  70. #define INT_MIN        (-INT_MAX-1)
  71.  
  72. #define UINT_MAX    (2U * INT_MAX + 1)
  73.  
  74. /*
  75.  * Maximum and minimum values for shorts.
  76.  */
  77. #define SHRT_MAX    32767
  78. #define SHRT_MIN    (-SHRT_MAX-1)
  79.  
  80. #define USHRT_MAX    ((unsigned short) (2U * SHRT_MAX + 1))
  81.  
  82. /*
  83.  * Maximum and minimum values for longs and unsigned longs.
  84.  *
  85.  * TODO: This is not correct for Alphas, which have 64 bit longs.
  86.  */
  87. #define LONG_MAX    2147483647L
  88.  
  89. #define LONG_MIN    (-LONG_MAX-1)
  90.  
  91. #define ULONG_MAX    (2UL * LONG_MAX + 1)
  92.  
  93.  
  94. /*
  95.  * The GNU C compiler also allows 'long long int'
  96.  */
  97. #if    !defined(__STRICT_ANSI__) && defined(__GNUC__)
  98.  
  99. #define LONG_LONG_MAX    9223372036854775807LL
  100. #define LONG_LONG_MIN    (-LONG_LONG_MAX-1)
  101.  
  102. #define ULONG_LONG_MAX    (2ULL * LONG_LONG_MAX + 1)
  103.  
  104. #endif /* Not Strict ANSI and GNU C compiler */
  105.  
  106.  
  107. #endif /* not _LIMITS_H_ */
  108.