Search code examples
c++linuxeclipsec-preprocessoreclipse-cdt

Build with different values in c++ Eclipse CDT


How can I do this in c++/Eclipse CDT ?

#if BUILD = DEBUG
#define DB_FILE="DB"
#elif BUILD = RELEASE
#define DB_FILE="/home/project/clientXY.DB"
....

Is there any configuration option in CDT that I can modify between the builds (to change the above parameters)?

many thanks in advance :D


Solution

  • i found the answer in the propeties of the project, if you want somekind of preprocessor process different between Debug and Release or any other, the only thing you have to do is:

    1. Properties of the project
    2. C/C++ Build
    3. Settings
    4. Tool Settings
    5. if you're working with C++ "GCC C++ Compiler" if you are not "GCC C Compiler"
    6. Preprocessor
    7. Under Defined Sumbols(-D) "Add..."
    8. there you write something like "XXX_BUILD" ,what i wrote "BUILD_RELEASE"
    9. Apply and OK

    remember to do this in both builds configuration.

    then in your code ( in my case in a header) you add the following

    #ifdef XXX_BUILD
     //something
     #include "someHeaderThatOnlyWorkOnXXX_BUILD.h"
    #elif YYY_BUILD
     //something else
     #include "someWhereElseThatWorksOnYYY_BUILD.h"
    #endif