home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / c / 17084 < prev    next >
Encoding:
Internet Message Format  |  1992-11-24  |  2.6 KB

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