PE> I am not sure anyone knows everything about C.
MS> Well, as far as standard C is concerned, I'm sure that the members
MS> of the ANSI & ISO committees,
Thanks to my 4000+ deep messagebase, refer to quote below.
PE> Another thing I only found out recently is that you have to go
PE> unsigned int xxx:1; in a structure, rather than unsigned short
PE> xxx:1;
MS> terms of a natural machine word. FWIW, I rarely use bitfields,
MS> since they are not portable & I'm quite comfortable with the bitwise
MS> arithmetic operators.
"portable" in what sense. If you are using them as internal
variables, they should be fine to use. If you are writing them
out to a file, then only chars will do. BFN. Paul.
P.S. Plauger has already been contacted, and admitted it was wrong.
I also contacted him about a bug in the ISO C standard, which even
needed an explanation of a possible scenario. (their example where
they use mktime()).
Date: 1993-01-19 20:13:06
From: Paul Edwards of 3:712/719.5
To: Nhan Tran
Subj: Paging PJ Plauger
Attr: scanned
Conf: AUST_C_HERE
/* Compiled with Borland C++ 2.0, in -->COMPACT<-- memory
model, repeate *COMPACT* memory model, this program prints out
the values 2 and 4. Does this violate the ANSI standard? */
/* According to P.J. Plauger, in his book "The Standard C
Library", ISBN 0-13-131509-9 on page 217, it certainly does,
to quote:
"When you subtract two pointers in a C expression, the result
has type ptrdiff_t. It is an integer type that can represent
negative values. Almost certainly it is either int or long.
It is always the signed type that has the same number of \
bits as the unsigned type chosen for size_t, described below.
(I said above that the use of these definitions is essentially
unrelated. These two definitions are themselves highly related.)"
*/
/* According to Paul Edwards, with reference to ISO/IEC 9899:1990,
it doesn't do anything of the sort. */
/* So who is right - the head of the ANSI C, ISO C and ANSI/ISO
C++ committees, or me? Could someone please contact P.J. Plauger
and ask him where he got his info from. If it says so in the ISO
standard, it is very well hidden. He can be contacted on either
Compuserve or Usenet (can't remember, but probably the former)
on the address indicated in August's Dr Dobbs Journal in the
article on wide character sets. I can be contacted on Fidonet
at address 3:712/502. Thanks for your help - I know some of
you have access to Compuserve, and I can hear you breathing!
BFN. Paul. */
#include
#include
int main(void)
{
printf("size_t is %d bytes\n",(int)(sizeof(size_t)));
printf("ptrdiff_t is %d bytes\n",(int)(sizeof(ptrdiff_t)));
return (0);
}
Paul.
@EOT:
---
* Origin: X (3:711/934.9)
|