David Brown said:
Yes, these type names are suitable for that purpose (though I am not
sure they are reserved for it by C99) - and it is the implementation
here that has failed to include them in <stdint.h> (I am not sure
whether this is the responsibility of the compiler or the library).
I commented on this a couple of days ago. I image the fact that
__int128 is in the compiler but int128_t is not it stdint.h is simply
the desire to keep the number of versions of stdint.h to a minimum.
Since C99 requires at least a 64-but int, limiting yourself to that
length keeps stdint.h very simple. However, I don't think gcc has the
mechanisms in place to make intmax_t be the 128-bit type (see below) and
that may be the real reason stdint.h stop st 64-bit types.
(A further reason might be simply that if you provide int128_t intmax_t
must be this type and all pre-processor arithmetic must be done using
it -- or at least *as if* it were being used.)
However, it is possible to express a 32-bit zero as "0", and a 64-bit
("long long") zero as "0LL". But there is no way to write a literal
128-bit zero, without extending C to allow "0LLL".
The "int128_t" and related types are enough to do most 128-bit integer
work in C. But there are unfortunately a number of places where the C
language and library specifications are tied to the poorly-defined
"int", "short", "long", "long long" types rather than size-specific
types.
But an implementation that has a 128-bit int can provide some
system-specific suffix (or, indeed, some other syntax) and stdint.h can
hide it to make the code portable. If your program needs a 128-bit
integer, you should be able to use int_least128_t and write constants
using INT128_C(value). gcc has provided __int128 but there is no
extension to write 128-bit constants yet. This may be the another
reason that stdint.h stops where it does.
This includes the suffixes on literals, and the format
specifiers in printf() (the "PRId32" style macros help enormously, but
they are not exactly elegant - and since they expand to specifiers for
short, int, long or long long, they can't support 128-bit integers).
I don't think that true. PRId128 could expand to some reserved but
currently unused length specifier. I don't think these macros are
limited to the specifiers for the standard integer types.