How to find out if __uint128_t is defined

We can use the preprocessor to find out if unsigned long long defined:

 #include <limits.h> #ifndef ULLONG_MAX typedef unsigned long t_mask; #else typedef unsigned long long t_mask; #endif 

But how do you know if __uint128_t is __uint128_t ?

+7
c c-preprocessor 128bit
source share
4 answers

Since the __uint128_t type is a GCC extension , the right thing is probably to check out some well-known version of GCC.

See this page for macros used to check the version of the GCC compiler.

+3
source share

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

 #ifdef __SIZEOF_INT128__ // do some fancy stuff here #else // do some fallback stuff here #endif 
+7
source share

I have not yet considered __uint128_t, but, based on the existing use of templates, I would expect the following.

 #include <stdint.h> #ifndef UINT128MAX #error "__uint128_t not defined" #endif 

Hope this helps

+5
source share

find your cc1 in the / usr / libexec / gcc tree, then do a poll:

 $ strings /usr/libexec/gcc/x86_64-redhat-linux/4.6.3/cc1 |  grep uint128_t
 __uint128_t (or not)
+1
source share

All Articles