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

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!olivea!charnel!sifon!thunder.mcrcim.mcgill.edu!mouse
  2. From: mouse@thunder.mcrcim.mcgill.edu (der Mouse)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Idle Questions about ANSI C
  5. Message-ID: <1992Nov17.123803.6400@thunder.mcrcim.mcgill.edu>
  6. Date: 17 Nov 92 12:38:03 GMT
  7. References: <1992Nov13.213708.5456@mccc.edu> <BxqBp1.5M6@netnews.jhuapl.edu>
  8. Organization: McGill Research Centre for Intelligent Machines
  9. Lines: 31
  10.  
  11. In article <BxqBp1.5M6@netnews.jhuapl.edu>, bandy@netnews.jhuapl.edu (Mike Bandy) writes:
  12. > pjh@mccc.edu (P. J. Holsberg) writes:
  13.  
  14. >> 1) Is "size_t" ever not the same as "unsigned int"?
  15.  
  16. It is allowed to be.
  17.  
  18. > According to K+R 2nd ed, section A7.4.8, size_t is "an unsigned
  19. > integral constant; the particular type in implementation defined".
  20.  
  21. Well, the result of sizeof is the quoted thing, and it notes that
  22. <stddef.h> defines the type in question as size_t.
  23.  
  24. Now: is it required that size_t be the same as one of the four usual
  25. unsigned integral types?  (How about ptrdiff_t?)
  26.  
  27. > If you need it to be unsigned int, then cast it's type explicitly;
  28. > this makes for more portable code.
  29.  
  30. Meaning, presumably, that you'd rather portably print the meaningless
  31. value generated by throwing away those extra bits.  (On a putative
  32. system which has size_t larger than unsigned int.)
  33.  
  34. If you need to print out a size_t and need it to be portable (as
  35. opposed to, say, debugging code), cast it to the largest unsigned type
  36. known to be available, unsigned long.
  37.  
  38.                     der Mouse
  39.  
  40.                 mouse@larry.mcrcim.mcgill.edu
  41.