Re: 64 bit pointer in C



jay <gl@xxxxxxxxxxxxxxxx> writes:

this oughta be simple, but somehow i can't blunder my
way on to it. it's probably a FAQ. either solaris compilers
or gcc ought to be enough of a hint for me -- if i have one
i expect i can find the other.

sizeof( int * ) for int, double, this, that, the other always
gives me 4 bytes. that means on a 64 bit machine w/
16GB memory i'll "run out" of addresses. are there compiler
options that will give me 64 bit pointer sizes?

$ cat pointer.c
#include <stdio.h>

#define DO_PTR_SIZE(type) printf("sizeof(%s *) = %d\n", #type, sizeof(type *))

int
main(void)
{
DO_PTR_SIZE(char);
DO_PTR_SIZE(short);
DO_PTR_SIZE(int);
DO_PTR_SIZE(long);
DO_PTR_SIZE(double);

return 0;
}



$ cc -m32 pointer.c
$ ./a.out
sizeof(char *) = 4
sizeof(short *) = 4
sizeof(int *) = 4
sizeof(long *) = 4
sizeof(double *) = 4

$ cc -m64 pointer.c
$ ./a.out
sizeof(char *) = 8
sizeof(short *) = 8
sizeof(int *) = 8
sizeof(long *) = 8
sizeof(double *) = 8


s/cc/gcc/ as required

hth
t
.



Relevant Pages

  • Re: 64 bit pointer in C
    ... either solaris compilers ... or gcc ought to be enough of a hint for me -- if i have one ... sizeof(int *) for int, double, this, that, the other always ...
    (comp.unix.solaris)
  • 64 bit pointer in C
    ... either solaris compilers ... or gcc ought to be enough of a hint for me -- if i have one ... sizeof(int *) for int, double, this, that, the other always ... options that will give me 64 bit pointer sizes? ...
    (comp.unix.solaris)
  • Re: 64 bit pointer in C
    ...  it's probably a FAQ. ... or gcc ought to be enough of a hint for me -- if i have one ...
    (comp.unix.solaris)