I'm editing some existing code, and in the code, there are several statements:
what does #if 0 do? It seems to me that it just ignores the code in between the if block??Code:#if 0 blah blha blha blah #endif
I'm editing some existing code, and in the code, there are several statements:
what does #if 0 do? It seems to me that it just ignores the code in between the if block??Code:#if 0 blah blha blha blah #endif
It's a way of disabling code in a way that is easily switchable -- you flip the switch by changing the 0 to a 1.
Normally this kind of thing is temporary. It might surround a piece of experimental code, or code that isn't quite ready for prime time yet. Using a constant 0 isn't as useful as a preprocessor macro, though:
This way the feature can be controlled from a header file or even a compiler switch (by defining the ENABLE_SOME_FEATURE symbol you can control the presence of the bit of code at compile time)Code:#if ENABLE_SOME_FEATURE ... #endif
Code://try //{ if (a) do { f( b); } while(1); else do { f(!b); } while(1); //}