C 11标准中的哪一节规定了原始数据类型大小之间的相对排序?

我试图找出C标准是否指定了各种类型的大小之间的关系.例如,https://stackoverflow.com/a/589599/1175080的答案似乎声称:

sizeof(short int) <= sizeof(int) <= sizeof(long int)

https://stackoverflow.com/a/589684/1175080的另一个答案有类似的说法:

sizeof(int) <= sizeof(long)

我正在经历n3337.pdf(我相信C 11标准的良好代理)但我找不到保证这些不等式的特定语言.

n1256(C99)中,我可以在5.2.4.2.1尺寸中找到特定的语言
整数类型清楚地说明每种类型的最小值和最大值,间接确定大小之间的相对排序.

这些不等式是否在C标准中类似地定义,还是直接从C继承?标准中的语言在哪里?

解决方法

在n3337中,该部分是 3.9.1,[basic.fundamental]/2,第二段(重点是我的):

There are five standard signed integer types : “signed char”,“short int”,“int”,“long int”,and “long long int”. In this list,each type provides at least as much storage as those preceding it in the list. There may also be implementation-defined extended signed integer types. The standard and extended signed integer types are collectively called signed integer types. Plain ints have the natural size suggested by the architecture of the execution environment44; the other signed integer types are provided to meet special needs.

请注意,C标准中的5.2.4.2/1仅定义了每个整数类型的最小范围,它不强制执行排序 – 我可以从-32767到32767使用int,从-2147483647到2147483647使用,并且仍然符合本节的要求.

但是6.2.5.8更加明确:

For any two integer types with the same signedness and different integer conversion rank (see 6.3.1.1),the range of values of the type with smaller integer conversion rank is a subrange of the values of the other type.

6.3.1.1告诉你:

The rank of long long int shall be greater than the rank of long int,which shall be greater than the rank of int,which shall be greater than the rank of short int,which shall be greater than the rank of signed char.

相关文章

本程序的编译和运行环境如下(如果有运行方面的问题欢迎在评...
水了一学期的院选修,万万没想到期末考试还有比较硬核的编程...
补充一下,先前文章末尾给出的下载链接的完整代码含有部分C&...
思路如标题所说采用模N取余法,难点是这个除法过程如何实现。...
本篇博客有更新!!!更新后效果图如下: 文章末尾的完整代码...
刚开始学习模块化程序设计时,估计大家都被形参和实参搞迷糊...