perlperl
asked on
if def in c++
I have the noticed the following in code path
How can we set the variable SOME, is this something set using environment variable from the bash shell before executing the executable?
#if SOME == 1
// Do someting
#else
// Do something
#endif
How can we set the variable SOME, is this something set using environment variable from the bash shell before executing the executable?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Just wanted to add (please do not award me any points, as you have already got your answer). The very same "variable" can be defined as a #define macro:
#define SOME 1
#if SOME == 1
// Do someting
#else
// Do something
#endif
Adding to the above comment,
In comanddline, we can only define a macro which helps for #ifdef/#ifndef ..etc. But for #if we have to specify a value to make it scence.
Ex:
#define SOME 1
......
......
#if SOME == 1
// Do someting===============>Th is wil execute.
#else
// Do something
#endif
########################## ########## ########## ########## #####
#if is simillar to if-else stateent but difference is, if-else is taking the value from variable and that variable needs to be defined. But in #if, it takes the value defined by #define
In comanddline, we can only define a macro which helps for #ifdef/#ifndef ..etc. But for #if we have to specify a value to make it scence.
Ex:
#define SOME 1
......
......
#if SOME == 1
// Do someting===============>Th
#else
// Do something
#endif
##########################
#if is simillar to if-else stateent but difference is, if-else is taking the value from variable and that variable needs to be defined. But in #if, it takes the value defined by #define
ASKER
Thanks a lot everyone for comments.
ASKER
Thanks a lot!!