C编译器为什么指定长为32位和long long是64位? [英] Why do C compilers specify long to be 32-bit and long long to be 64-bit?
问题描述
那岂不是更有意义,使长64位和长长的保留,直到128位的数字成为现实?
Wouldn't it have made more sense to make long 64-bit and reserve long long until 128-bit numbers become a reality?
推荐答案
是的,这有一定道理,但微软有自己的理由定义为32位长。
Yes, it does make sense, but Microsoft had their own reasons for defining "long" as 32-bits.
据我所知,所有现在主流的系统,Windows是长是32位的唯一操作系统。在Unix和Linux,它是64位的。
As far as I know, of all the mainstream systems right now, Windows is the only OS where "long" is 32-bits. On Unix and Linux, it's 64-bit.
对于Windows所有的编译器编译长在Windows 32位,以保持与微软的兼容。
All compilers for Windows will compile "long" to 32-bits on Windows to maintain compatibility with Microsoft.
由于这个原因,我避免使用Int和长。偶尔我会用INT错误codeS和布尔(C语言),但我从来没有把它们用于任何code是依赖于类型的大小。
For this reason, I avoid using "int" and "long". Occasionally I'll use "int" for error codes and booleans (in C), but I never use them for any code that is dependent on the size of the type.
这篇关于C编译器为什么指定长为32位和long long是64位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!