I know that I can kick the the preprocessor to spit out output with the -E
option in my particular circumstance. For generated code this preprocessor output is
For an editor, Eclipse CDT works quite well. It shows which code is active and which code is #ifdef'ed out, it provides syntax highlighting within code that's #ifdef'ed out so you can still easily read it, and it can step through macro expansions one at a time if you mouse over a macro.
From the command line, cpp -dM filename.c
processes a file and shows only the #defines that are in effect. For example, in your code, it might spit out
#define DLEVEL 5
#define SIGNAL 1
#define STACK 200
#define STACKUSE 1
without cluttering the listing with other preprocessor directives or with C/C++ code.
(On a related note, cpp -dM /dev/null
is a handy way to find predefined macros for your platform.)
If you're a Linux user and you also use GNOME then I would have to recommend GEdit. I really loved it after I installed some plugins for Intellisense, file browsing, etc... If you're not running GNOME but are still using Linux (KDE) you might be able to use Kate. I didn't play with it for too long so I don't have much to say about that. GEdit will work in KDE but it won't look right.
If you're using Windows and have a really good PC then try Netbeans (yeah it's for C++ also, not just Java). If not there's always Visual C++ 2008 (still pretty RAM dependent though).
I'm not sure about Mac as I can't afford one, but Netbeans works on it also (as well as Linux).
Emacs has hide-ifdef-mode (I've never had to use it myself, so I can't vouch for its quality)
Consider looking at "Son of Unifdef", cited in the answer to Is there a C pre-processor which eliminates #ifdef blocks based on values defined/undefined?. This isn't a visual editor - it would, however, take C code (or code with C preprocessor directives in it) and generate a modified file which you could then compare with the original.
I'm curious about the mention of Informix 4GL (I4GL). The C code it generates is not, AFAIK, laced with #ifdef
constructs. At least, the output was not allowed to contain any when I was in charge of it. (Which version of I4GL are you using?) There are lots of #line
entries; those permit you to chase the generated code back to the corresponding I4GL source. I have a script that converts those into simple C comments so that I can use a debugger (gdb
or dbx
or ... perish the thought, sdb
or adb
) on the compiled code. And I have also seen preprocessors (both cpp
and m4
) used to generate I4GL source code for submission to the I4GL compiler.
You can also try unifdef which is rather simpler than sunifdef.
The Eclipse CDT editor does a pretty good job highlighting code based on the macros you declare to be active. You may want to check it out.