无符号 __int128 文字 GCC
Unsigned __int128 literal GCC
我有一个函数foo(unsigned __int128)
。
如何将 unsigned __int128
类型的文字传递给函数?
我的尝试:
foo(0xFFFFFFFFFFFFFF23FFFFF); //Truncated (expected)
foo(0xFFFFFFFFFFFFFFF01FFFu); //Truncated (expected)
foo(0xFFFFFFFFFFFFFFF23FFFFull); //Truncated
foo((unsigned __int128)0xFF45FFFFFFFFFFFFFFFFFull); //Truncated
如您所见,所有这些都被截断了。
我如何向 GCC 发出信号,即文字是 unsigned __int128
?
编辑:
gcc 手册说:
There is no support in GCC for expressing an integer constant of type __int128 for targets with long long integer less than 128 bits wide
这是否意味着我无法编写类型为(无符号)__int128 的文字?
有其他选择吗?
来自https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html
6.9 128-bit Integers
As an extension the integer scalar type __int128 is supported for targets which have an integer mode wide enough to hold 128 bits. Simply write __int128 for a signed 128-bit integer, or unsigned __int128 for an unsigned 128-bit integer. There is no support in GCC for expressing an integer constant of type __int128 for targets with long long integer less than 128 bits wide.
所以,不,你不能有一个文字 128 位常量
我有一个函数foo(unsigned __int128)
。
如何将 unsigned __int128
类型的文字传递给函数?
我的尝试:
foo(0xFFFFFFFFFFFFFF23FFFFF); //Truncated (expected)
foo(0xFFFFFFFFFFFFFFF01FFFu); //Truncated (expected)
foo(0xFFFFFFFFFFFFFFF23FFFFull); //Truncated
foo((unsigned __int128)0xFF45FFFFFFFFFFFFFFFFFull); //Truncated
如您所见,所有这些都被截断了。
我如何向 GCC 发出信号,即文字是 unsigned __int128
?
编辑: gcc 手册说:
There is no support in GCC for expressing an integer constant of type __int128 for targets with long long integer less than 128 bits wide
这是否意味着我无法编写类型为(无符号)__int128 的文字?
有其他选择吗?
来自https://gcc.gnu.org/onlinedocs/gcc/_005f_005fint128.html
6.9 128-bit Integers
As an extension the integer scalar type __int128 is supported for targets which have an integer mode wide enough to hold 128 bits. Simply write __int128 for a signed 128-bit integer, or unsigned __int128 for an unsigned 128-bit integer. There is no support in GCC for expressing an integer constant of type __int128 for targets with long long integer less than 128 bits wide.
所以,不,你不能有一个文字 128 位常量