16

Under the gcc docs 128-bit integers is:

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.

I was wondering what gcc version added support for this type, or if there's a macro that can be used directly to test for its existence.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Peeter Joot
  • 7,848
  • 7
  • 48
  • 82

2 Answers2

13

Not sure about the first version, but you can test for the __SIZEOF_INT128__ macro - which is (typically) 16 if defined.

Brett Hale
  • 21,653
  • 2
  • 61
  • 90
8

Get the source and:

git log --reverse --grep='__int128'

to see the first occurrence of the word on a commit message.

This leads us to: https://github.com/gcc-mirror/gcc/commit/6388cfe24f7ecbdc2ba2d4c80638ea6c95ba07c2 which says:

Add __int128 keyword.

Then list all tags that contain that commit with:

git tag --contains 6388cfe24f7ecbdc2ba2d4c80638ea6c95ba07c2

and the earliest one is:

gcc-4_6_0-release

TODO: there is also an earlier reference to __int128_t which I did not understand. What is the difference between __int128 and _int128_t?

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
  • 6
    Normally, _t suffix means a typedef, __ prefix means reserved for compiler and _ prefix means reserved for standard library; I would guess that __int128 is the final native type supported by the compiler, while _int128_t was a temporary hack that they moved away from. – Jay Freeman -saurik- Jan 03 '16 at 19:36
  • 1
    searching for `__int128` doesn't work, because it was `__int128_t` on older gcc versions. 128-bit int has been supported since [at least gcc 4.1.2](https://stackoverflow.com/a/5576526/995714) – phuclv Apr 21 '19 at 15:53