Alex Rivera | Logout

How to add a custom MACRO when using NDK?

Asked 2010-10-26T09:10:35.033
17

I need some custom MACROs in my NDK projects however I have no ideal how to add and I found no answers Could anyone please help? Many thanks!

Edit
Report

1 Answer

52

If you would like to add a special definition when compiling your NDK code (jni) add the following into your Android.mk:

LOCAL_CFLAGS    := -DMYDEFINE

This will define the Macro MYDEFINE in your c/c++ code. Here an example

#ifdef MYDEFINE
// We build the project with this special macro
#else
// We build without setting the macro in the LOCAL_CFLAGS
#endif
answered 2010-10-26T10:15:42.347

Your Answer