How to know if __uint128_t is defined

You can try the following. I do not know how reliable this is, but it might be the easiest way.

#ifdef __SIZEOF_INT128__
    // do some fancy stuff here
#else
    // do some fallback stuff here
#endif

I have not yet dealt with __uint128_t, but based on existing pattern usage, I would expect the following.

#include <stdint.h>

#ifndef UINT128MAX
    #error "__uint128_t not defined"
#endif

Hope this helps


Since the __uint128_t type is a GCC extension, the proper thing to do is probably to check for some known-good version of GCC.

See this page for information about the macros used to version-check the GCC compiler.