Re: 32 bit processors / 64 bit processors

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

 




On Oct 21, 2009, at 2:31 PM, Denis Kirjanov wrote:

Just did a comparison test but it tells me otherwise. But I'm not sure if the test case if correct, can someone improve it?
On a 64bit CentOS:
[root@yyan ~]# more test.c
#include <stdio.h>

int main ()
{
   printf ("%d\n", sizeof(int));
   return 0;
}
[root@yyan ~]# gcc test.c
[root@yyan ~]# ./a.out
4
[root@yyan ~]# uname -a
Linux yyan.pmlab.com 2.6.18-128.el5 #1 SMP Wed Jan 21 10:41:14 EST 2009 x86_64 x86_64 x86_64 GNU/Linux
[root@yyan ~]#
Yeah, sizeof(int) is 4, but what about sizeof(void*) ?)

Right, here's the real deal:

simonmac:coding yansimon$ uname -a
Darwin simonmac.local 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386
simonmac:coding yansimon$ more test.c
#include <stdio.h>

int main ()
{
    printf ("sizeof int is %d\n", sizeof(int));
    printf ("sizeof void* is %d\n", sizeof(void*));
    return 0;
}
simonmac:coding yansimon$ gcc test.c
simonmac:coding yansimon$ ./a.out
sizeof int is 4
sizeof void* is 4

[root@yyan ~]# cat test.c
#include <stdio.h>

int main ()
{
    printf ("sizeof int is %d\n", sizeof(int));
    printf ("sizeof void* is %d\n", sizeof(void*));
    return 0;
}
[root@yyan ~]# gcc test.c
[root@yyan ~]# ./a.out
sizeof int is 4
sizeof void* is 8
[root@yyan ~]# uname -a
Linux yyan.pmlab.com 2.6.18-128.el5 #1 SMP Wed Jan 21 10:41:14 EST 2009 x86_64 x86_64 x86_64 GNU/Linux




On my Leopard: (Hopefully it's a 32bit OS as it shows)
simonmac:coding yansimon$ cat test.c
#include <stdio.h>

int main ()
{
   printf ("%d\n", sizeof(int));
   return 0;
}
simonmac:coding yansimon$ gcc test.c
simonmac:coding yansimon$ ./a.out
4
simonmac:coding yansimon$ uname -a
Darwin simonmac.local 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386
simonmac:coding yansimon$




Lastly, How are "sizes" of compiler / OS / processor inter related?
Here is my understanding. A 32 bit processor can only be running a 32
bit OS.

No ... 32 bit OS can run anything <= 32 bit

A 64 bit processor may run a 32 or a 64 bit OS.

yes thats right !

A 32 bit
compiler genrates code only to be run on a 32 bit OS; ditto for 64
bit
Not sure about this let others have their say !
Is this right?

Yes it is, unlike the cross-compiler.


--
Regards,
Denis

--
益牙

http://www.google.com/profiles/simonyanix


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux