[cfe-users] Use of undeclared identifier '_tzcnt_u64'

Jeffrey Walton via cfe-users cfe-users at lists.llvm.org
Sat Jun 25 18:41:17 PDT 2016


Hi Everyone,

We got a user report of a compile failure using Apple's Clang. I don't
know the exact Apple Clang version at the moment. Its on OS X 10.11,
and its probably the one bundled with the latest Xcode.

Here's the error report
(https://groups.google.com/forum/#!topic/cryptopp-users/BI8yGpr2XNo):

    misc.h:675:23: error: use of undeclared identifier '_tzcnt_u64'
    misc.h:790:22: error: use of undeclared identifier '_blsr_u64';
did you mean '__blsr_u32'?

Here's the code in question from misc.h (from
http://github.com/weidai11/cryptopp/blob/master/misc.h):

#if defined(__GNUC__) && defined(__BMI__)
    return (unsigned int)_tzcnt_u64(v);
#elif defined(__GNUC__) && (GCC_VERSION >= 30400)
    return (unsigned int)__builtin_ctzll(v);
#elif ...
    ....
#endif

And from misc.h (from http://github.com/weidai11/cryptopp/blob/master/misc.h):

#if defined(__GNUC__) && defined(__BMI__)
template <>
inline bool IsPowerOf2<word64>(const word64 &value)
{
    return value > 0 && _blsr_u64(value) == 0;
}
#endif

I believe both symbols are available in <immintrin.h>
http://software.intel.com/sites/landingpage/IntrinsicsGuide/#=undefined&text=_blsr_u64&expand=421):

#if defined(__GNUC__) && defined(__BMI__)
    #include <immintrin.h>
#endif


Given __BMI__ is defined, why are we catching the "undeclared identifier" error?

Thanlk in advance/


More information about the cfe-users mailing list