Skip to main content

Detecting the SPECS Target in Code

Use the SPECSNDK macro and SpecsNDKVersion.h to detect a SPECS NDK build and gate code on the NDK version at compile time.

The SPECS NDK toolchain gives your code two compile-time signals: the SPECSNDK macro, which tells you the build targets SPECS, and the version macros in SpecsNDKVersion.h, which tell you which NDK release you build against.

Check for a SPECS build with SPECSNDK

The toolchain defines SPECSNDK as a preprocessor macro for all builds:

#ifdef SPECSNDK
// SPECS-specific code path
#else
// Non-SPECS fallback
#endif

Gate code on the NDK version

SpecsNDKVersion.h exposes the NDK release version as compile-time macros, so code can gate on the SDK version at build time:

#include <SpecsNDKVersion.h>

#define SPECS_NDK_AT_LEAST(maj, min, pat) \
(SPECS_NDK_VERSION_MAJOR > (maj) || \
(SPECS_NDK_VERSION_MAJOR == (maj) && (SPECS_NDK_VERSION_MINOR > (min) || \
(SPECS_NDK_VERSION_MINOR == (min) && SPECS_NDK_VERSION_PATCH >= (pat)))))

#if SPECS_NDK_AT_LEAST(1, 3, 0)
// Code that requires NDK 1.3.0 or later
#endif

The header defines SPECS_NDK_VERSION_MAJOR, SPECS_NDK_VERSION_MINOR, SPECS_NDK_VERSION_PATCH, and the string SPECS_NDK_VERSION_STRING ("1.3.0" in this release).