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
It won't - because the preprocessor strips comments before it starts thinking about macro sustitution!
If you want just the "active" stuff, you need to work with actual references - rather than just doing text searches.
In uVision, use the Code Browser.
CodeWright can be configured to hide inactive lines, but I'm note sure if it can search only on active references.
Eclipse can search only on active references .
please check for notepad++ and regular expressions, other tools like sed and gawk may be better but needs more effort.
notepad++ http://notepad-plus-plus.org/
sed gnuwin32.sourceforge.net/.../sed.htm
gawk gnuwin32.sourceforge.net/.../gawk.htm
regular expressions (regex or regexp) en.wikipedia.org/.../Regular_expression
Yes, that's the crux.
I was hoping for something like "//" or '/''/' or #pragma real// or ....
#ifdef INCLUDE_BLAH #define BLAH BLAH void blah(void) BLAH { ....
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.
I don't see how Regular Expressions could help?
Regular Expressions are about text searching - and that's not going to work.
What is needed is something that's aware of what is and is not "active"...
How about using the preprocessor output...?
www.cs.washington.edu/.../
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...)