Compiling Android x86 gives error in bitops.h. Cannot find int ffs(int)

I tried to compile my project in Android Studio with APP_ABI := armeabi armeabi-v7a x86

The build fails as the compiler cannot find the ffs() in bitops.h. The ffs function is available in strings.h in the NDK but is compiled out with:

(defined(LP64)) || (defined(mips)) || (defined(arm)) || (defined(i386) && ANDROID_API >= 18)

I’m using API 16 and cocos2dx 3.15.

Any help would be greatly appreciated!

1 Like

Hi, I had the same problem after update NDK to version 15. I replaced it by version 14b and now it works.

Thanks for the reply! I’ll try that and let you know.

Hi,
I downloaded last release of Cocos2d-x and have this issue also

cocos2d/cocos/audio/android/../../audio/android/cutils/bitops.h:65:30: error: 'ffs' was not declared in 
this scope
       bit = ffs(~bitmask[i]);

Any solutions for this !!! …
i m using NDK r15b x86_64

temporary solution for me and it works … was to copy past declaration for ffs from strings.h inside bitops.h and keep headers as they are defined
like this :

  __BEGIN_DECLS
   int ffs(int) __INTRODUCED_IN_X86(18);
   __END_DECLS
3 Likes

This works 100%
By the way, What is the meaning of the code ‘__INTRODUCED_IN_X86’? <-- Is it inline function defined in macro?

Is it macro constant? Can someone explain what it is?

That problem is caused by ndk version change and auto enabled unified header.
Am I saying right?