c - Testing for builtins/intrinsics -


i have code uses gcc intrinsics. include code in case intrinsic missing. how can this?

#ifdef __builtin_ctzll 

does not work.

with recent versions of clang possible check if builtin intrinsics exist using __has_builtin() macro e.g.

int popcount(int x) { #if __has_builtin(__builtin_popcount)   return __builtin_popcount(x); #else   int count = 0;   (; x != 0; x &= x - 1)     count++;   return count; #endif } 

let's hope gcc support __has_builtin() in future.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -