【发布时间】:2016-11-17 05:54:48
【问题描述】:
ISO C 标准规定A "plain" int object has the natural size suggested by the architecture of the execution environment
不过,也保证 int 至少和 short 一样大,至少 16 位大小。
8 位处理器(例如 6502 或 8080)建议的自然大小似乎是 8 位 int,但是这会使 int 短于 16 位。 那么,在这些 8 位处理器之一上 int 会有多大?
【问题讨论】:
-
C 和 C++ 保证
sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long) <= sizeof(long long),因此int永远不会小于short,即使“自然”大小是其他的。 C++ 保证short至少为 16 位。不确定 C 是否做出同样的保证。 -
N1548 的第 5.2.4.2.1 节:
SHRT_MAX和INT_MAX必须至少为32767