I have a piece of code as shown below:
#define FEATURE_A 1 void function() {
The program does not execute code inside #ifdef - #endif . But when I change #ifdef to #ifndef and delete the #define macro, the code runs. The code below works as expected.
//#define FEATURE_A 1 void function() { // some code #ifndef FEATURE_A // code to be executed when this feature is defined #endif // some code }
Can someone explain why in the first case the code inside #ifdef - #endif is not executed, and in the second case it works? Can someone tell me which setting might be wrong?
Not sure if I am using visual studio 2010 in this case.
Thanks in advance
UPDATE: When I clean and start up again, the second one doesn't work either. his only show in the editor as code included.
When I define the macro in the project-> property-> Configuration Properties-> c / C ++ β Preprocessor file, both of them work fine.
c ++ macros
someone_ smiley
source share