home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!ukma!darwin.sura.net!zaphod.mps.ohio-state.edu!uunet.ca!wildcan!sq!msb
- From: msb@sq.sq.com (Mark Brader)
- Subject: Re: Idle Questions about ANSI C
- Message-ID: <1992Nov17.155826.15087@sq.sq.com>
- Organization: SoftQuad Inc., Toronto, Canada
- References: <1992Nov13.213708.5456@mccc.edu> <BxqBp1.5M6@netnews.jhuapl.edu> <1992Nov17.123803.6400@thunder.mcrcim.mcgill.edu>
- Date: Tue, 17 Nov 92 15:58:26 GMT
- Lines: 39
-
- > > 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?)
-
- The wording of section 3.1.2.5/6.1.2.5 of the standard clearly implies
- that the 9 "usual" integral types are the only ones. They consist of
- 4 signed integer types, 4 unsigned integer types, and char -- which
- of course can be either signed or unsigned. Since size_t and ptrdiff_t
- are specified respectively as unsigned or signed *integral* types, not
- *integer* types, then an implementation could actually use char for
- one of them -- remember, it could be the same size as int or even long.
- So there are 5 possibilities for each.
-
- There *are* implementations that define extra integral types -- the
- appendix even mentions this as a common extension. However, I don't
- see how an implementation could be conforming if it made size_t, say,
- a type that was longer than long.
-
- Threads that are purely about ANSI C, as this one is according to its
- subject line, are better placed in comp.std.c. If someone wants to
- dispute the above conclusions in terms of the standard, I suggest they
- crosspost to comp.std.c and direct followups there.
-
- A side remark since I *am* writing in comp.lang.c.... the computer on
- which I'm typing this has a pre-ANSI implementation in which size_t
- is provided, not in one of the standard C headers, but in the UNIX
- header <sys/types.h> ... and size_t is *int*. And in fact sizeof
- appears to return int also; at least, "sizeof(char) < -1" is false,
- whereas in ANSI C it's true.
- --
- Mark Brader, SoftQuad Inc., Toronto, utzoo!sq!msb, msb@sq.com
- #define MSB(type) (~(((unsigned type)-1)>>1))
-
- This article is in the public domain.
-