Tobias DiPasquale on 27 Apr 2004 01:41:02 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Re: #define for 32 vs 64 bit C program?


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Monday 26 April 2004 21:15, Chip Salzenberg wrote:
| 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.

I can reason just fine, thank you, having written several compilers in the 
past. The "rules" you speak of are a factor of the compiler's intended 
audience and the architecture of the machine. If the intended audience of the 
compiler is a modern architecture with an intelligent memory model, it 
doesn't make any sense NOT to have unsigned long be equal to the word size 
(regardless of what int's size is). Besides, as someone pointed out, 
__WORDSIZE is available in limits.h if you need a more secure method of 
determining the word size on a given machine.

Speaking of this issue, the Linux kernel handles the word size issue nicely. 
You might want to check that out to see how its really done ;-)

| * 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 remember. It hasn't been that long. ;-)

- -- 
Tobias DiPasquale
202A 04C4 2CE6 B985 8520  88D6 CD25 1A6C B9B5 1595
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAjboDzSUabLm1FZURAvSYAJ4tSUw8/ZxB+xLAtB4GG8atqquQiwCeJUCC
rlnOKfjMuuGLQvuG+mKqi1U=
=vqf+
-----END PGP SIGNATURE-----
___________________________________________________________________________
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