Reputation: 2003
I have read many posts that for a 16 bit system the sizeof(ptr)
should be 2 byte , for a 32 bit system sizeof(ptr) = 4 byte
and for a 64 bit system sizeof(ptr) = 8
byte and it makes sense also but on my machine which has a 64 bit OS (4 GB RAM) its says the sizeof(ptr) = 4 byte
. Can someone explains it to me. Thanks
Upvotes: 1
Views: 119
Reputation: 3475
You mentioned in the comments you're using Visual Studio. To setup this compiler to build 64bit solutions the following will work for Visual Studio 2010, 2012, and 2013. The steps below were taken from the Microsoft MSDN site.
Active solution configuration
New
and enter a name for this configuration. i.e. Debug64 or Release64Copy settings from
and Choose Win32. Copying from Win32 will automatically update multiple settings to 64bit.Active solution platform
choose New
You should now be building for the x64 platform and your pointers will be size 8.
To change back to 32bit, open the configuration manager again and choose the correct Configuration
and Platform
.
Upvotes: 0
Reputation: 10868
The Intel CPUs have the ability to execute 16, 32 and 64-bit binaries. The question is: which were you testing?
Both Windows and Linux are available in 32 and 64-bit versions. The difference is that 32-bit cannot execute 64-bit binaries, whereas 64-bit can.
If (and only if) you have a 64-bit OS and a 64-bit-capable development system and you write a program and explicitly tell it to generate a 64-bit program then when you run it you will see 8 byte pointers.
Upvotes: 2