4

Is there a way to use __int128_t with the Android NDK?

I tried to use GNU toolchain 4.9 but I get the following error no matter how I try: error: '__int128_t' was not declared in this scope

-std=gnu++11 is enabled of course.

Mat
  • 202,337
  • 40
  • 393
  • 406
Tamas
  • 3,254
  • 4
  • 29
  • 51

1 Answers1

1

Is there a way to use __int128_t with the Android NDK?

I don't believe so. __int128_t is emulated, and its only available on 64-bit platforms. Its not available on Android at the moment, which is a 32-bit platform. See Is __int128_t arithmetic emulated by GCC, even with SSE?.

You can check for availability of __int128_t by detecting the presence of the macro __SIZEOF_INT128__. If the macro is defined and the value is 16 or more then 128-bit types are available. Also see 128-bit integer - nonsensical documentation? on the GCC mailing list.

jww
  • 97,681
  • 90
  • 411
  • 885
  • Exactly because it is emulated, I though that it should be available on 32-bit platforms as well. – Tamas Sep 13 '14 at 11:12
  • 2
    it will be available on ARM64, MIPS64 or x86_64. @Tamas emulated operations are only supported for values that are twice the register width – phuclv Feb 20 '15 at 16:21
  • @phuclv - Do you recall which NDK first provided 64-bit support? – jww Aug 30 '18 at 13:27
  • 1
    I don't use NDK but [the first gcc with `__int128_t` I can confirm is 4.1.2](https://stackoverflow.com/a/5576526/995714#comment90833163_5576526) – phuclv Aug 30 '18 at 13:58
  • 3
    64 bit support was introduced for android-21, Lollipop, which was released in Nov.2014. Corresponding NDK, r. 10, became official in July that year. I am not sure it had `__int128_t` then. – Alex Cohn Aug 30 '18 at 16:20