C++ 中 64 位计算机的指针大小是多少? [英] What the pointer size in 64 bits computer in C++?
问题描述
我的电脑从 32 位变为 64 位,我的操作系统是 64 位 Windows 7.我认为 64 位操作系统中的指针应该是 64 位 -- 8 个字节.但是,当我在C++中使用sizeof(void*)获取一个点的大小时,结果是4.
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.
为什么是 4??
推荐答案
您的可执行文件仍在编译为 32 位二进制文件.尝试将其编译为 64 位项目.
Your executable is still being compiled as a 32-bit binary. Try compiling it as a 64-bit project.
如果处理器在 32 位环境中模拟程序,则操作系统对指针的内部大小没有影响...
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...
在 VS2010 中,转到配置管理器,在平台"下创建一个新条目,然后选择 x64
(通常这是唯一的其他选项)
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)
另外,请确保您将 void*
传递给 sizeof()
运算符.
Also, make sure you're passing a void*
to the sizeof()
operator.
这篇关于C++ 中 64 位计算机的指针大小是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!