c语言中128位unsigned int的使用

use of 128 bit unsigned int in c language

我需要在我的代码中使用 128 位 unsigned int 变量。
在线搜索我读到 unsigned __int128。 这里https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html我读

type __int128 is supported for targets which have an integer mode wide enough to hold 128 bits

我的第一个问题是 target 是什么意思?我必须检查我的电脑是否可以表达这种类型?
第二个问题是如何打印这样的变量?
最后我需要做些什么来使用这种变量吗?同上link说

Simply write __int128 for a signed 128-bit integer, or unsigned __int128 for an unsigned 128-bit integer.

所以我似乎不需要 #include 任何东西,甚至在编译过程中我都没有在 gcc 中添加一些选项,对吗?

  1. “目标”是指编译器配置为其创建程序的 CPU 体系结构和操作系统的特定组合。 Does a list of all known target triplets in use exist? 有讨论。但是“整数模式”实际上是编译器内部使用的一个概念,只与硬件能做什么和不能做什么有间接关系。所以这一切真正说的是“编译器在某些目标上支持 128 位整数,而在其他目标上不支持”。找出你是否这样做的最简单方法是尝试编译 运行 一个使用 __int128.

    的小测试程序
  2. 大部分系统的printf函数不支持__int128,所以你要自己写代码打印,或者找第三方代码。请参阅 How to print __int128 in g++?,它适用于 C++,但仍然相关。

  3. 您不需要包含任何内容或使用任何特殊选项。