Apologies if this is a stupid question, but when using VisualGDB (in this case with VS 2008), where do you define preprocessor definitions? I have tried under the normal VS project settings, where there is a Preprocessor Definitions section. This appears to only be applied to the InitelliSense.
I intend to have several different build targets (e.g. Debug, Release). In my cpp code, the #ifdef DEBUG works in the UI (as in the intellisense greys-out the correct portions of the code). This define does not appear to be applied to the built binary (the code nested in the #ifdef DEBUG is not executed). Do I need to add a -DDEBUG in some other settings window?
No problem. The definitions in the Project Settings indeed apply to IntelliSense only. To change the actual definitions, please edit the flags.mak file in the project directory. The default flags.mak file contains the following definitions:
If it does not help, please rebuild the project and post the entire build log here. It will help understanding why the definitions were not applied.
Apologies, I neglected to mention that this is an Android project made using VisualGDB. I have constructed it using the Android App Wizard. Using the wizard, no flags.mak file has been generated, nor is one referenced in my Android.mk file.
Under this build environment, is it still a case of adding the macros in some make file? –
DEBUG_MACROS := DEBUG
RELEASE_MACROS := NDEBUG RELEASE”
I have tried adding include flags.mak to my Android.mk, where the flags file only contains the above text, but this appears not to work.
When you are generating Android projects, the underlying makefile structure is 100% compatible with the classical NDK makefiles and thus adding new preprocessor definitions is done exactly like for the normal NDK projects (see docsandroid-mk.html).
In your case please add the following text to Android.mk (before the include $(BUILD_SHARED_LIBRARY) line):