spartygw
spartygw

Reputation: 3462

How can I get the NDK version during compile time?

I've searched and it seems that at some point __NDK_MAJOR__ was at least proposed but at least as of NDK 15c it doesn't seem to be set.

Is there a way within the preprocessor to determine the NDK version being used to build from source?

Upvotes: 3

Views: 1851

Answers (2)

kenping
kenping

Reputation: 51

try these:

#include <android/api-level.h>
#ifdef __ANDROID_API_O_MR1__
#    include <android/ndk-version.h>
#    ifdef __NDK_MAJOR__
#        define MY_NDK_VERSION   __NDK_MAJOR__
#    else
#        define MY_NDK_VERSION   16
#    endif
#else
#    define MY_NDK_VERSION       14
#endif

Upvotes: 1

Dan Albert
Dan Albert

Reputation: 10519

It's in r16. If you need to know the version before then, you'll need to parse the $NDK/source.properties file and pass it as a define to your code as part of your build system.

Upvotes: 3

Related Questions