Article 194 of unix-pc.sources: Path: tut.cis.ohio-state.edu!mailrus!ames!ll-xn!mit-eddie!andante!alice!wilber From: wilber@alice.UUCP (My name is already in the article, you stupid postnews program) Newsgroups: unix-pc.sources,comp.sys.att Subject: limits.h for the Unix PC Keywords: Here it is Message-ID: <8256@alice.UUCP> Date: 2 Oct 88 03:13:54 GMT Organization: AT&T Bell Laboratories, Murray Hill NJ Lines: 83 Xref: tut.cis.ohio-state.edu unix-pc.sources:194 comp.sys.att:3948 Here's an ANSI C compatible limits.h file for the Unix PC. Put it in /usr/include. (And stop putting those "magic constants" in your code. :-) Bob Wilber wilber@research.att.com -------------- Cut Here ---------------------------------------------------- #ifndef LIMITS_DOT_H #define LIMITS_DOT_H /* ANSI C compatible limits.h file for the 3b1. If your C compiler doesn't understand the U suffix for unsigned constants, define NOT_ANSI_C at the front of this file (or before you include it). */ #define NOT_ANSI_C /* Stock 3b1 CC can't handle U. GCC should be able to. */ /* Bits in a char. */ #define CHAR_BIT 8 /* Maximum value of a char. (3b1 uses signed chars.) */ #define CHAR_MAX SCHAR_MAX /* Minimum value of a char. */ #define CHAR_MIN SCHAR_MIN /* Maximum value of an int. */ #define INT_MAX 2147483647 /* Minimum value of an int. */ #define INT_MIN (-2147483648) /* Maximum value of a long. */ #define LONG_MAX 2147483647L /* Minimum value of a long. */ #define LONG_MIN (-2147483648L) /* Maximum value of a signed char. */ #define SCHAR_MAX 127 /* Minimum value of a signed char. */ #define SCHAR_MIN (-128) /* Maximum value of a short. */ #define SHRT_MAX 32767 /* Minimum value of a short. */ #define SHRT_MIN (-32768) #ifdef NOT_ANSI_C /* Maximum value of an unsigned char. */ #define UCHAR_MAX ((unsigned int) 255) /* Maximum value of an unsigned int. */ #define UINT_MAX ((unsigned int) 4294967295) /* Maximum value of an unsigned long. */ #define ULONG_MAX ((unsigned long) 4294967295L) /* Maximum value of an unsigned short. */ #define USHRT_MAX ((unsigned int) 65535) #else /* Maximum value of an unsigned char. */ #define UCHAR_MAX 255U /* Maximum value of an unsigned int. */ #define UINT_MAX 4294967295U /* Maximum value of an unsigned long. */ #define ULONG_MAX 4294967295UL /* Maximum value of an unsigned short. */ #define USHRT_MAX 65535U #endif #endif /* LIMITS_DOT_H */