I have a function foo(unsigned __int128)
.
How can I pass a literal of type unsigned __int128
to the function?
My attempts:
foo(0xFFFFFFFFFFFFFF23FFFFF); //Truncated (expected)
foo(0xFFFFFFFFFFFFFFF01FFFu); //Truncated (expected)
foo(0xFFFFFFFFFFFFFFF23FFFFull); //Truncated
foo((unsigned __int128)0xFF45FFFFFFFFFFFFFFFFFull); //Truncated
As you can see, all of them are truncated.
How can I signal GCC, that an literal is an unsigned __int128
?
Edit: The gcc manual says:
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
Does that mean, that I can't write literals of type (unsigned) __int128?
Are there alternatives?
From 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.
So, no, you cannot have a literal 128-bit constant