Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22006

Strange address of a C variable in Mac OS X

$
0
0

Given the following C code:

void *ptr;ptr = malloc(100);printf("Address: %p\n", ptr);

When compiling this code using GCC 4.9 in Ubuntu 64 bit and running it the output is similar to this:

Address: 0x151ab10

The value 0x151ab10 seems a reasonable number since my machine has 8 GB of RAM, but when compiling the same code using GCC 4.9 in Mac OS X 64 bit and running it, it gives an output similar to this:

Address: 0x7fb9cb43ed30

... which is strange because 0x7fb9cb43ed30 is well above the 8 GB of RAM. Is there some kind of bit masking that one has to do in Mac OS X so that the real address of ptr can be printed out?


Viewing all articles
Browse latest Browse all 22006

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>