I am working on some stuff with 4711 #ifdefs and, on most global searches, end up looking at inactive code.
To obtain 'marked' code lines I tried to replace
#ifdef BLAH .......
with //#define BLAH #define BLAH // BLAH ....
this works for BLAH = nothing, but I can't find a way to make it work for '//'
any ideas?
Erik
You're not being terribly clear what it is you're actually looking for, but I suspect the closest equivalent would be
#ifdef USE_FEATURE_FOO # define FOO_ONLY(x) x #else # define FOO_ONLY(x) /*nothing*/ #endif FOO_ONLY(whatever code;) FOO_ONLY(and more of it;)
But in the end, if you have enough of such code to make that kind of cruft look like an option worth having, you need to find an entirely different editing tool (one that actually knows the difference between C code and alphabet soup). Or a different coding strategy.
Hans-Bernhard,
is what you propose not doing the same as what I posted above?
#ifdef INCLUDE_BLAH #define BLAH BLAH void blah(void) BLAH {
No. Because your BLAH define is basically just a comment. It doesn't do anything. You might as well have stuck to an actual comment:
#ifdef INCLUDE_BLAH /*BLAH*/ void blah(void) /*BLAH*/ { /* oh, and you forgot this: */ #endif
The difference with my approach is that there's only one #ifdef needed. Every line that would otherwise have to be included into another pair of
#ifdef INCLUDE_BLAH BLAH-only stuff here... #endif
can just be put in the BLAH_ONLY() macro instead:
BLAH_ONLY(BLAH-only stuff here...)