[英]Maximum size of size_t
I know in C
return type of sizeof
operator is size_t
being unsigned integer type defined in <stdint.h>
.我知道在C
中sizeof
运算符的返回类型是size_t
是<stdint.h>
定义的无符号整数类型。 Which means max size of it should be 65535
as stated in C99
standard 7.18.3 :这意味着它的最大大小应该是65535
如C99
标准7.18.3 中所述:
limit of size_t
SIZE_MAX 65535
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,然而,在gcc-4.8.2
头文件stdint.h
中定义了它的大小远远大于65535
与C99
标准中的规定相矛盾,如下所示,
/* Limit of `size_t' type. */
# if __WORDSIZE == 64
# define SIZE_MAX (18446744073709551615UL)
# else
# define SIZE_MAX (4294967295U)
# endif
Kindly help me in understanding why there is a difference or reason behind my misinterpretation.请帮助我理解为什么我的误解背后存在差异或原因。
The standard says that SIZE_MAX
must be at least 65535.标准规定SIZE_MAX
必须至少为65535。
It specifies no upper bound, and gcc's implementation is perfectly valid.它没有指定上限,gcc 的实现是完全有效的。
Quoting the reference you cited (emphasis added):引用你引用的参考文献(强调):
Its implementation-defined value shall be equal to or greater in magnitude (absolute value) than the corresponding value given below, with the same sign.其实现定义的值应等于或大于下面给出的相应值的幅度(绝对值),并具有相同的符号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.