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