What the pointer size in 64 bits computer in C++?

14,951

Solution 1

Your executable is still being compiled as a 32-bit binary. Try compiling it as a 64-bit project.

The operating system makes no difference to the internal size of a pointer if the processor is emulating the program within a 32-bit environment...

In VS2010, head over to the configuration manager, make a new entry under 'platform', and select x64 (usually it's the only other option there)

EDIT: Also, make sure you're passing a void* to the sizeof() operator.

Solution 2

Are you compiling in 64-bit mode or 32-bit mode? In Visual Studio you need to select the CPU type of the compilation, and the default might be 32-bit.

Also, make sure you do sizeof(void*).

Share:
14,951

Related videos on Youtube

2power10
Author by

2power10

Updated on August 06, 2022

Comments

  • 2power10
    2power10 5 months

    My computer is change from 32 bits to 64 bits, and my operating system is 64 bits Windows 7. I think the pointer in 64 bits operating system should be 64 bits -- 8 bytes. However, when I use sizeof(void*) in C++ to get the size of a point, the result is 4.

    Why 4??

    • gregseth
      gregseth
      Are you sure you compiled your program in 64bits ?
  • 2power10
    2power10 over 11 years
    Thank you for your answer, it help me a lot.

Related