home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!oracle!unrepliable!bounce
- Newsgroups: comp.lang.c
- From: wkaufman@us.oracle.com (William Kaufman)
- Subject: Re: Typedefing builtin... thanks.
- Message-ID: <1992Nov24.025730.6953@oracle.us.oracle.com>
- Sender: usenet@oracle.us.oracle.com (Oracle News Poster)
- Nntp-Posting-Host: hqsun2.us.oracle.com
- Organization: Oracle Corporation, Redwood Shores CA
- References: <1992Nov9.150414.10221@odin.diku.dk> <1992Nov17.235519.24646@pure.com> <1992Nov20.164732.8121@cimage.com>
- Date: Tue, 24 Nov 1992 02:57:30 GMT
- X-Disclaimer: This message was written by an unauthenticated user
- at Oracle Corporation. The opinions expressed are those
- of the user and not necessarily those of Oracle.
- Lines: 40
-
- In article <1992Nov20.164732.8121@cimage.com> ejd@cimage.com (Ed Driscoll) writes:
- ] In article <1992Nov17.235519.24646@pure.com> rpeck@pure.com (Ray Peck) writes:
- ] >[...#define'ing WORD...]
- ]
- ] I've been thinking about doing it that way myself, but it seems to me that
- ] you would want two variants of each size: one for when you need EXACLTY
- ] that number of bits, and one when you just need AT LEAST that number of
- ] bits.
-
- If you ever need *exactly* n bits, you'll find yourself frustrated
- eventually. What set of #defines will give you exactly 8 bits on a
- machine with 9-bit chars and 36-bit ints?
-
- (Before you reply: Yes, they exist. Honeywell/Bull machines are
- like this. Also, some machines allowed 6-bit bytes, at the programmers
- option. And, saying you'll never work on one of these is the surest way
- to make sure that you will.)
-
- Using a set of "at least" macros, though, is fine, as long as you're
- willing to limit yourself to reasonably large machines: there *are*
- machines out there without 32-bit ints, after all.
-
- ] The former type would be used where the exact size matters (say,
- ] something you're reading from a file, or something used for bit flags).
-
- You should never write binary data when you expect to move data
- between different machines; and, if you aren't moving binary data
- between machines, you'll never need this type. (See the FAQ, section
- 17.2.)
-
- The suggestion wrt flags is correct, though; and, you can restrict
- the set of macros to unsigned types. But, because you can't be certain
- about the size of the types available, this is really an "at least"
- type: you need to address at least N bits, not exactly N bits.
-
- -- Bill K.
-
- Bill Kaufman, | "Hush my darling / Be still my darling /
- Corporate Lackey | The lion's on the phone,..."
- wkaufman@us.oracle.com | -- "The Guitar", They Might Be Giants
-