How to know if __uint128_t is defined

David Ranieri picture David Ranieri · Aug 30, 2013 · Viewed 16.4k times · Source

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?

Answer

firefexx picture firefexx · Jun 1, 2014

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