Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!xn!cullvax!drw From: drw@cullvax.UUCP (Dale Worley) Newsgroups: comp.lang.c Subject: Portable integer types Message-ID: <1103@cullvax.UUCP> Date: Thu, 16-Apr-87 14:36:52 EST Article-I.D.: cullvax.1103 Posted: Thu Apr 16 14:36:52 1987 Date-Received: Sun, 19-Apr-87 06:31:32 EST Organization: Cullinet Software, Inc., Westwood, MA Lines: 24 Under the new ANSI standard, if you want to, say, define a type 'int12' that has at least 12 bits (signed), you can write: #include #if CHAR_MAX >= 2047 typedef signed char int12; #elif SHRT_MAX >= 2047 typedef signed short int12; #elif INT_MAX >= 2047 typedef signed int int12; #elif LONG_MAX >= 2047 typedef signed long int12; #else #error No integer type wide enough for 12 bits! #endif And it's portable! Dale -- Dale Worley Cullinet Software UUCP: ...!seismo!harvard!mit-eddie!cullvax!drw ARPA: cullvax!drw@eddie.mit.edu Un*x (a generic name for a class of OS's) != Unix (AT&T's brand of such)