Chip Salzenberg on 27 Apr 2004 01:16:02 -0000 |
According to Tobias DiPasquale: > On Monday 26 April 2004 20:04, Chip Salzenberg wrote: > | Except where it's not. > > Please delineate where, in practice, sizeof( unsigned long) would not be equal > to the word size of the platform using an ANSI compliant C compiler. It's entirely up to the implementor whether to make long and int the same size, and if they're different, which of them to make the natural word size of the machine. These rules may not make much sense to you, but they're all a compiler writer has to go on. Assuming that he'll be "reasonable" doesn't work when he reasons differently. * The examples I know best, Intel 8088 through 80286, are seldom remembered these days except in mockery, but the 286 had real memory protection and was a decent platform for Unix (or, alternatively, Xenix :-)). I'm sure you'll agree that 16 bits was the native size for those machines. On these pre-386 machines: short = int = 16bits long = 32bits Porting code written for VAXen was "fun". BTW, pointers were all different depending on the memory model, but I won't bore you with that. Suffice to say that there's a *reason* why the ANSI standard says that a function pointer type is not guaranteed to be castable to *any* type other except another function pointer type. * I also used several compilers for 8-bit processors; in fact, I once retargeted a compiler from the Z-80 to the 6809. Eight-bit compilers typically followed the same pattern: int=short=16, long=32. * A reader might infer from this that there wasn't a lot of difference between an 8086 and an eight-bit processor. He would be right. :-P -- Chip Salzenberg - a.k.a. - <chip@pobox.com> "I wanted to play hopscotch with the impenetrable mystery of existence, but he stepped in a wormhole and had to go in early." // MST3K ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
|
|