Sysprogs forums › Forums › VisualGDB › MSVStudio #define passed to C/C++ per configuration
Tagged: C/C++ defines with flavors
- This topic has 4 replies, 2 voices, and was last updated 9 years, 2 months ago by wademaxfield.
-
AuthorPosts
-
September 18, 2015 at 15:11 #6941wademaxfieldParticipant
I googled, and searched in the forums, but could not find an answer.
I am sure I am overlooking something obvious.
I have a mix of Java and C code, with flavors.
I would like to set up a #define and pass it to the C/C++ compiler on a per-configuration basis, to support different flavors.
I tried the Makefile Settings, but the CXXFLAGS shows up on *all* configurations/flavors.
For now, I have to manually change the #define in a header file for each flavor I compile.
Can someone tell me how to do this? I’m rather dumb when it comes to this, so more information is better than less information. I usually end up puzzled with answers.
September 22, 2015 at 23:31 #6961supportKeymasterYou can add something like “MYVAR=1” to the ndk-build command-line arguments and then check it from your Android.mak:
ifeq($(MYVAR),1) LOCAL_CFLAGS += -DTEST endif
Let us know if you need more details.
September 26, 2015 at 18:56 #6978wademaxfieldParticipantThank you for your reply. Unfortunately, that does not work, but thanks for trying! It may not be possible under android.
in My Android.mk file: (also tried LOCAL_CPP_FLAGS)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)ifeq ($(AVB_VER),1)
LOCAL_C_FLAGS += -DAVB_OVERRIDE
LOCAL_C_FLAGS += -DAVB_BEGINNER_VER
endifin my header file:
#ifdef AVB_OVERRIDE
#ifdef AVB_AVB_BEGINNER_VER
#pragma message(“Beginner Defined”)
#define IVB_VERSION_NUMBER IVB_BEGINNER
#endif#ifdef AVB_AVB_BASIC_VER
#pragma message(“Basic Defined”)
#define IVB_VERSION_NUMBER IVB_BASIC
#endif#else
#pragma message(“version defined inside ivdefines.h”)#define IVB_VERSION_NUMBER IVB_BASIC /* ivb pro is 4.0*/
#endifin my output:
VisualGDB: Run “c:\android-ndk-r10d\ndk-build.cmd NDK_DEBUG=1 APP_PLATFORM=android-14 VGDB_VSCONFIG=Debug__BeginnerFree_ AVB_VER=1” in directory “C:\Users\cti\Dropbox\AVBasic\AVBasic\app” on local computer
1> [x86] Gdbserver : [x86-4.8] libs/x86/gdbserver
1> [x86] Gdbsetup : libs/x86/gdb.setup
1> [armeabi] Gdbserver : [arm-linux-androideabi-4.8] libs/armeabi/gdbserver
1> [armeabi] Gdbsetup : libs/armeabi/gdb.setup
1> [x86] Compile++ : avBasicLibrary <= avbasic.cpp
1> In file included from jni/javabridge\javabridge.h:4:0,
1> from jni/avbasic.cpp:2:
1> C:\Users\cti\Dropbox\AVBasic\AVBasic\app\jni\common\ivdefines.h(43,54): note: #pragma message: version defined inside ivdefines.h
1> #pragma message(“version defined inside ivdefines.h”)September 26, 2015 at 18:57 #6979wademaxfieldParticipantNote that even though I had an inner #ifdef incorrect (AVB_AVB_BEGINNER_VER), my answer still stands. The AVB_OVERRIDE path was obviously not taken.
September 26, 2015 at 19:00 #6980wademaxfieldParticipantOOPS!!!!!! FOUND IT!!! LOCAL_CFLAGS, not LOCAL_C_FLAGS!!!!
-
AuthorPosts
- You must be logged in to reply to this topic.