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
Post a Comment