MSVStudio #define passed to C/C++ per configuration

Sysprogs forums Forums VisualGDB MSVStudio #define passed to C/C++ per configuration

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #6941
    wademaxfield
    Participant

    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.

    #6961
    support
    Keymaster

    You 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.

    #6978
    wademaxfield
    Participant

    Thank 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
    endif

    in 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*/
    #endif

     

    in 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”)

     

     

    #6979
    wademaxfield
    Participant

    Note 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.

     

    #6980
    wademaxfield
    Participant

    OOPS!!!!!! FOUND IT!!! LOCAL_CFLAGS, not LOCAL_C_FLAGS!!!!

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.