Search code examples
cc-preprocessor128-bit

How to know if __uint128_t is defined


We can use the preprocessor to know if unsigned long long is defined:

#include <limits.h>

#ifndef ULLONG_MAX
typedef unsigned long t_mask; 
#else
typedef unsigned long long t_mask;
#endif

But how to know if __uint128_t is defined?


Solution

  • 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