Reputation: 1587
I recently installed a 64bit OS on my computer, I thought that sizeof(char*)
would give me 8 instead of 4. Shouldn't I get a 64 bit addresses in my pointers?
Upvotes: 1
Views: 180
Reputation: 182769
The OS typically has no effect on code generation. If you run the same compiler and the same libraries, you will get the same code out, regardless of whether the OS is 32-bits or 64-bits. You can compile and run 32-bit software on a 64-bit OS. You can compile 64-bit software on a 32-bit OS.
The compiler determines the type of code generated. The OS only determines whether you can run it.
Upvotes: 1
Reputation: 80276
Yes, you should, but note that a same operating system can run both 32-bit and 64-bit code, and that in the "64bit OS" you installed, the "64bit" may only mean "64bit able".
You really should give more detail here about the particulars of the OS. Mac OS X Snow Leopard , for instance, comes with versions of GCC and Clang that default to 64-bit code, and you can use option -m32
to generate 32-bit code. Perhaps the convention is reversed on your 64-bit OS (that is, you should use -m64
or a similar option)
Upvotes: 0
Reputation: 612963
This is because the compiler you are using is emitting 32 bit code. If you use a 64 bit compiler then pointers will be 8 bytes wide.
Note that most 64 bit systems have the ability to run 32 bit code under an emulation layer. On Windows the emulation layer is known as WOW64. This is clearly what is happening here.
Upvotes: 7