我会参考C标准;我认为C标准继承了< stdint.h>的规则。 /< cstdint>从C.

我知道gcc实现128位有符号和无符号整数,名称__int128和unsigned __int128(__int128是一个实现定义的关键字)在一些平台上。

即使对于提供标准128位类型的实现,该标准不需要定义int128_t或uint128_t。引用C标准N1570草案第7.20.1.1节:

These types are optional. However, if an implementation provides

integer types with widths of 8, 16, 32, or 64 bits, no padding bits,

and (for the signed types) that have a two’s complement

representation, it shall define the corresponding typedef names.

C允许实现定义的扩展整数类型,其名称是实现定义的关键字。 gcc的__int128和unsigned __int128非常类似于标准定义的扩展整数类型 – 但gcc不会这样处理。相反,它将它们视为语言扩展。

特别是,如果__int128和unsigned __int128是扩展整数类型,则需要gcc来定义intmax_t和uintmax_t作为这些类型(或者至少128位宽)。它不这样做;相反,intmax_t和uintmax_t只有64位。

这在我看来是不幸的,但我不相信它使gcc不符合。没有可移植程序可以依赖__int128的存在,或者任何宽于64位的整数类型。

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐