问题描述
我知道 C
的的sizeof
操作符返回类型为size_t
在中所定义是无符号整型; stdint.h>
。这意味着它的最大尺寸应 65535
在 C99陈述
标准的:
I know in C
return type of sizeof
operator is size_t
being unsigned integer type defined in <stdint.h>
. Which means max size of it should be 65535
as stated in C99
standard 7.18.3:
limit of size_t
SIZE_MAX 65535
然而,在 GCC-4.8.2
头文件 stdint.h
定义比<$其规模大得多C $ C> 65535 矛盾给在 C99
标准如下图所示,
However in gcc-4.8.2
header file stdint.h
has defined its size much greater than 65535
contradicting to which is stated in C99
standard as below shown,
/* Limit of `size_t' type. */
# if __WORDSIZE == 64
# define SIZE_MAX (18446744073709551615UL)
# else
# define SIZE_MAX (4294967295U)
# endif
请帮助我理解为什么有我的背后misinter pretation的差异或理由。
Kindly help me in understanding why there is a difference or reason behind my misinterpretation.
推荐答案
该标准说 SIZE_MAX
必须的至少的65535。
The standard says that SIZE_MAX
must be at least 65535.
它规定没有上限,以及gcc的实现是完全有效的。
It specifies no upper bound, and gcc's implementation is perfectly valid.
引用您引用的参考(强调):
Quoting the reference you cited (emphasis added):
其实现定义的值应等于或大于比下面给出的同号的对应值幅度(绝对值)。
这篇关于为size_t的最大大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!