Re: amd64: why is sizeof(int) =4? why not =8?
On Wednesday 05 April 2006 15:16, Mike McCarty wrote:
> This program has defects. The type of the results of
> the sizeof operator is an unsigned integer of unspecified
> size. The only portable way to do this is...
> printf("Size of int is %lu\n",(unsigned long)sizeof(int));
Why do I have cast something from size_t? I see the construct I used in
"C a reference Manual" by Harbisson and Steele p148.
I am not a c expert - and I dont understand why you do the cast.
Do you have an example of a compiler where the length of sizeof(int) is
greater than size_t ?
> > and the output is no different from on my 32 bit system.
> As expected. Once the compiler is run, and the program
> created, the instructions are whatever they are. There is
> no run time size detection and re-writing of the program.
> C is not an interpreted language.
> You need to get a 64 bit compiler. The programs it creates will
> not run on a 32 bit machine, and likely not with a 32 bit OS
> even on your 64 bit machine.
I was (of course) using gcc - a 64 bit compiler on the debian 64 bit system.
I compiled the same program on each system - one a 32 bit and one a 64 bit
compiler/ kernel etc.
The problem that I needed help with was -
as was pointed out by Hendrik and Ron
1) we need to declare using int64 to get 64 bit integers and
2) we always now have 64 bit addresses
which i can test for with int * or int64*.
> This message made from 100% recycled bits.
> You have found the bank of Larn.
> I can explain it for you, but I can't understand it for you.
> I speak only for myself, and I am unanimous in that!