How to detect compilation by Android NDK in a C/C++ file?

前端 未结 3 1813
梦毁少年i
梦毁少年i 2020-12-24 04:53

Is there a preprocessor macro that will let me know NDK is compiling my code? I could manually define my own, but I\'d rather not if possible.

3条回答
  •  旧巷少年郎
    2020-12-24 05:25

    Short answer: #ifdef ANDROID .

    The ANDROID macro is defined for you in build-module.mk (part of the standard build system):

    # always define ANDROID when building binaries
    #
    LOCAL_CFLAGS := -DANDROID $(LOCAL_CFLAGS)
    

提交回复
热议问题