64位windows下long是几字节

nwao7890 2010-09-03 11:13:22
刚才在win7 64下sizeof(long)是4字节。。。不应该是8字节吗
...全文
2752 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2010-09-03
  • 打赏
  • 举报
回复 1
不要迷信书、考题、老师、回帖;
要迷信CPU、编译器、调试器、运行结果。
feitianliuyun 2010-09-03
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 jluluoshi88 的回复:]
long的字节数与你所使用的编译器有关,因此建议测试一下你的编译器下各类型的字节数
[/Quote]
pengzhixi 2010-09-03
  • 打赏
  • 举报
回复
和编译器和系统都有关
jluluoshi88 2010-09-03
  • 打赏
  • 举报
回复
long的字节数与你所使用的编译器有关,因此建议测试一下你的编译器下各类型的字节数
nwao7890 2010-09-03
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 justkk 的回复:]
还与你的程序的编译模式有关吧
如果你编译为32的应用程序,那long通常是4字节
如果你编译为64的应用程序,那long通常是8字节
[/Quote]
VS2005用的X64编译项
justkk 2010-09-03
  • 打赏
  • 举报
回复
还与你的程序的编译模式有关吧
如果你编译为32的应用程序,那long通常是4字节
如果你编译为64的应用程序,那long通常是8字节
nwao7890 2010-09-03
  • 打赏
  • 举报
回复
In 64-bit Microsoft® Windows®, this assumption of parity in data type sizes is invalid. Making all data types 64 bits in length would waste space, because most applications do not need the increased size. However, applications do need pointers to 64-bit data, and they need the ability to have 64-bit data types in selected cases. These considerations led to the selection of an abstract data model called LLP64 (or P64). In the LLP64 data model, only pointers expand to 64 bits; all other basic data types (integer and long) remain 32 bits in length.
果然是记错了。windows64下long 是4字节!
herman~~ 2010-09-03
  • 打赏
  • 举报
回复
跟编译器和系统相关
maosher 2010-09-03
  • 打赏
  • 举报
回复
long 4 long int,signed long int –2,147,483,648 到 2,147,483,647
longlong 8 none (but equivalent to __int64) –9,223,372,036,854,775,808 到 9,223,372,036,854,775,807
maosher 2010-09-03
  • 打赏
  • 举报
回复
数据类型名称 字节数 别名 取值范围

int * signed,signed int 由操作系统决定,即与操作系统的"字长"有关
unsigned int * unsigned 由操作系统决定,即与操作系统的"字长"有关
__int8 1 char,signed char –128 到 127
__int16 2 short,short int,signed short int –32,768 到 32,767
__int32 4 signed,signed int –2,147,483,648 到 2,147,483,647
__int64 8 无 –9,223,372,036,854,775,808 到 9,223,372,036,854,775,807
bool 1 无 false 或 true
char 1 signed char –128 到 127
unsigned char 1 无 0 到 255
short 2 short int,signed short int –32,768 到 32,767
unsigned short 2 unsigned short int 0 到 65,535
long 4 long int,signed long int –2,147,483,648 到 2,147,483,647
long long 8 none (but equivalent to __int64) –9,223,372,036,854,775,808 到 9,223,372,036,854,775,807
unsigned long 4 unsigned long int 0 到 4,294,967,295
enum * 无 由操作系统决定,即与操作系统的"字长"有关
float 4 无 3.4E +/- 38 (7 digits)
double 8 无 1.7E +/- 308 (15 digits)
long double 8 无 1.7E +/- 308 (15 digits)
wchar_t 2 __wchar_t 0 到 65,535
luoqi 2010-09-03
  • 打赏
  • 举报
回复
4 byte
老邓 2010-09-03
  • 打赏
  • 举报
回复
Windows的64位,long是4byte
Linux下的64位,long是8byte
chb1991123 2010-09-03
  • 打赏
  • 举报
回复
貌似和 编译器 有关系

65,176

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧