Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site umcp-cs.UUCP Path: utzoo!linus!genrad!mit-eddi!mit-vax!eagle!harpo!seismo!rlgvax!cvl!umcp-cs!chris From: chris@umcp-cs.UUCP Newsgroups: net.lang.c Subject: Re: type casting problem Message-ID: <139@umcp-cs.UUCP> Date: Sat, 11-Jun-83 00:27:13 EDT Article-I.D.: umcp-cs.139 Posted: Sat Jun 11 00:27:13 1983 Date-Received: Sat, 11-Jun-83 11:08:50 EDT References: decvax.112, <1607@yale-com.UUCP> Organization: Univ. of Maryland, Computer Science Dept. Lines: 32 If you're willing to pick up a bunch of other cruft you can #include (at least on x.yBSD) and get the constant NBBY, number of bits per byte. You also get NBPW, number of bytes per word. You unfortuantely get all sorts of uninteresting stuff as well. As for generating extract-macros, getting masks is easy: #define UNSIGNEDCHAR(c) ((c)&((1<>NBBY) How about an include file called , containing lots of things like the above, and/or the version of C being run (say perhaps #define MANY_UNSIGNEDS means the compiler understands unsigned long and unsigned char)? Possibly these might just be macros, or even typedefs as in : on a Vax running 4BSD typedef unsigned char u_char; #define U_CHAR(c) (c) on an 11/45 running V7 typedef char u_char; #define U_CHAR(c) ((c)&0377) and so on. At least the ``fundamental constants'' (NBBY, NBPW) should be available someplace other than . - Chris ({allegra,seismo}!umcp-cs!chris)