How does APP_OPTIM manifest in code?

匿名 (未验证) 提交于 2019-12-03 02:56:01

问题:

In Application.mk you can set:

APP_OPTIM := release APP_OPTIM := debug 

How can I test for release/debug build in C++?

I'm assuming there are defines so I've tried this, but only "NOT" messages are logged:

#ifdef RELEASE     LOGV("RELEASE"); #else     LOGV("NOT RELEASE"); #endif  #ifdef DEBUG     LOGV("DEBUG"); #else     LOGV("NOT DEBUG"); #endif 

回答1:

In android-ndk-r8b/build/core/add-application.mk we read:

ifeq ($(APP_OPTIM),debug)   APP_CFLAGS := -O0 -g $(APP_CFLAGS) else   APP_CFLAGS := -O2 -DNDEBUG -g $(APP_CFLAGS) endif 

So, to answer your question: in NDK r8b (the latest for today) you can check

#ifdef NDEBUG // this is "release" #else // this is "debug" #endif 

But you can add any other compilation flags through your Android.mk or Application.mk depending on $(APP_OPTIM), if you want.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!