6

As of C99, C supports implementation-defined extended integer types (6.2.5 p7). Does any implementation actually implement an extended integer type?

I'm aware of gcc's __int128, which is currently treated as a language extension and is not formally listed as an extended integer type in gcc's documentation of implementation-defined behavior (J.3.5). I couldn't find anything mentioned in the documentation for clang or MSVC. Solaris states that there are no extended integer types.

There is some related discussion at What are “extended integer types”?, but the only other candidate mentioned is __int64 in an older version of MSVC, and the comments seem to agree that it's not a formal extended integer type due to that version of MSVC being C90.

ov2k
  • 295
  • 1
  • 10
  • 2
    Perhaps [int24_t](https://www.microchip.com/forums/m1081917.aspx)? – chux - Reinstate Monica Aug 02 '19 at 19:23
  • Curious. The GCC manual does say that `__int128` is available only on platforms that have a wide enough integer mode. Is it in fact available anywhere where it is not an alias for one of the standard integer types (presumably `long long int`)? – John Bollinger Aug 02 '19 at 19:32
  • @chux Please make that an answer. – ov2k Aug 02 '19 at 19:43
  • @JohnBollinger gcc (Ubuntu 8.3.0-6ubuntu1) has 64-bit `long`, `long long`, and `intmax_t` and provides `__int128` in a Ubuntu 19.04 VM. – ov2k Aug 02 '19 at 19:53
  • 2
    `__int128` in GCC is not an “extended integer type” in the sense of the C standard. Let me look up the quote from a GCC developer… But for one, it is wider than `intmax_t` on, say, x86-64, which a normal extended integer type cannot be. – Pascal Cuoq Aug 02 '19 at 20:05
  • Yes, exactly for that reason: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84764 “__int128 is not an extended integer type in the C sense. The main reason is because intmax_t is not defined as __int128.” – Pascal Cuoq Aug 02 '19 at 20:08
  • Interesting, @PascalCuoq, especially in its backwardness. `__int128` being neither a standard nor an extended integer type effectively means that the language standard does not define any behavior for it. I suppose there must be some reason that that choice was preferable to making `intmax_t` be `__int128` on those machines that support the latter. – John Bollinger Aug 02 '19 at 20:19
  • @PascalCuoq another reason is that there are no literal values for int128 – Antti Haapala -- Слава Україні Aug 02 '19 at 20:47

1 Answers1

2

Example of an extended integer type?
Does any implementation actually implement an extended integer type?

Various processors have a 24-bit width for instructions and constant memory.

Compilers supporting such Microchip processors offer (u)int24_t.

int24_t types added to C99 The int24_t and uint24_t types (along with the existing __int24 and __uint24 types) are now available when using the C99 library and when CCI is not active.


Even though some compilers do offer 128-bit integer types, if that type was an extended integer type, the C library would require (u)intmax_t to be at least that width. C11dr 7.20.1.5

C also requires "preprocessor arithmetic done in intmax_t/uintmax_t".

I suspect compilers offering intN (N > 64) do so as a language extension.

I know of no compiler where (u)int128_t exist (as an extended integer type).

chux - Reinstate Monica
  • 143,097
  • 13
  • 135
  • 256