是什么决定了sizeof的整数?整数、决定了、sizeof

2023-09-07 17:59:54 作者:疯子丶

的sizeof(int)的 4显示在我的开发.cpp的尽管它在64位计算机上运行。为什么它不考虑底层的硬件,并显示8呢?另外,如果我编译环境也改变了,以64位(难道一个 64位编译器有道理摆在首位?!),将INT变化那么大小?

sizeof(int) shows 4 on my Dev Cpp even though its running on a 64 bit machine. Why doesn't it consider the underlying HW and show 8 instead? Also, if I compiling environment also changes to 64 bit ( Does a 64 bit compiler makes sense in the first place?! ), would size of int change then?

有没有这决定对此有何标准?

Are there any standards which decide this?

推荐答案

从 http://en.wikipedia.org拍摄/维基/ 64位(下 64位数据模型

有各种型号,微软决定的sizeof(int)的== 4 ,一些(少数),另一些则没有。

There are various models, Microsoft decided that sizeof(int) == 4, some (a few) others didn't.

从Solaris到SPARC64和UNICOS的HAL计算机系统接口似乎是唯一的,其中的sizeof(int)的== 8 。他们被称为ILP64和SILP64模型。

HAL Computer Systems port of Solaris to SPARC64 and Unicos seem to be the only ones where sizeof(int) == 8. They are called ILP64 and SILP64 models.

真正的战争对于的sizeof(长),其中微软决定为的sizeof(长)== 4 (LLP64),而几乎每个人都决定了的sizeof(长)== 8 (LP64)。

The true "war" was for sizeof(long), where Microsoft decided for sizeof(long) == 4 (LLP64) while nearly everyone else decided for sizeof(long) == 8 (LP64).

请注意,在真理那就是决定要使用的模型编译器,但写在维基

Note that in truth it's the compiler that "decides" which model to use, but as written in the wiki

请注意,一个编程模型是由在每个编译基础的选择和几个可以在同一操作系统上共存。然而,选定为操作系统API主模型的规划模型通常占主导地位。

Note that a programming model is a choice made on a per-compiler basis, and several can coexist on the same OS. However, the programming model chosen as the primary model for the OS API typically dominates.