user923005
10/22/2009 8:22:00 PM
On Oct 22, 11:55 am, Nobody <nob...@nowhere.com> wrote:
> On Wed, 21 Oct 2009 11:48:49 -0700, user923005 wrote:
> > There are a few compilers which have int = 64 bits on 64 bit hardware
> > (even though this is a very sensible default),
>
> The problem is that "char" really *has* to be 8-bit, so if it "int" is
> 64-bit, "short" can be either 16-bit or 32-bit, but the other one ceases
> to be available.
>
> Also, C's type promotion rules mean that anything smaller than an "int"
> gets promoted to an "int" at the drop of a hat, which makes working with
> code which was written assuming a 32-bit "int" a nightmare.
>
> It's much easier to have a 32-bit "int" and a 64-bit "long", so that you
> can work with both 32-bit and 64-bit values without excessive promotions.
>
> Although, even that was too much trouble for Windows, which is heavily
> tied to the 80386 architecture, so Win64 has a 32-bit "long" as well.
>
> > but almost all of them
> > have not done it that way. So (for instance) for an Intel platform I
> > think it will be very hard to find a compiler that does what you want.
>
> What use would such a compiler be? You wouldn't be able to use any of the
> standard headers; wherever the headers say "int", the corresponding object
> code in the libraries will be assuming a 32-bit value. All of the popular
> OSes for x86_64 (i.e. Win32, Win64, Linux, MacOSX, *BSD) use a 32-bit "int".
>
> > You need ILP64 or SILP64.
>
> IOW, you need the HP (formerly Compaq (formerly DEC)) Alpha architecture.
It is not just a function of the hardware, but also a function of the
compiler.
Consider:
Next Cmd: type t.c
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
printf("size of char is %u\n", (unsigned) sizeof(char));
printf("size of short is %u\n", (unsigned) sizeof(short));
printf("size of int is %u\n", (unsigned) sizeof(int));
printf("size of long is %u\n", (unsigned) sizeof(long));
printf("size of long long is %u\n", (unsigned) sizeof(long
long));
return EXIT_SUCCESS;
}
Next Cmd: run t
size of char is 1
size of short is 2
size of int is 4
size of long is 4
size of long long is 8
Next Cmd: sho cpu
ALPHA1, a AlphaStation 200 4/100
Multiprocessing is DISABLED. Uniprocessing synchronization image
loaded.
Minimum multiprocessing revision levels: CPU = 1