Doron Yakovlev-Golani Doron Yakovlev-Golani - 20 days ago 5
C++ Question

How to expand C++ macro in Android Studio?

I am writing C++ code in Android Studio and using macros.
For example:

#define USE_KEY(param) "KEY_" #param, param
void Keys::saveToPreferences() {
setString(USE_KEY(token));
}


I want to see the expansion of the macro in the IDE to verify it is working as I expect (same as is available in Eclipse in the explore macro expansion functionality).

So for this example the macro expansion would be:

setString("KEY_" "token", token);


Is this feature available in Android Studio?

Answer

Found the answer. This feature is called macro replacement and not expansion in Android Studio. It is available by default when you hover over a macro with the mouse (you need to expand the box to see it like this):

Screen shot from Android Studio

Comments