Alex Rivera | Logout

Is there any cure for the preprocessor blues?

Asked 2009-04-11T00:17:33.857
10

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 murderous. For example I have a 4gl application and Informix converts this into C which in turn gets spit out to a horrible ugly mess.

What I want is an editor that will allow me to specify what preprocessor values are in effect and show me only the relevant code. I have something very basic working in Vim matching #ifdef and #endif, but the code is riddled with more advanced constructs such is #ifndef, #if, and #else. To make matters worse, the constructs are logically more complex, and I don't think my Vim scripting skills are adequate for me to get what I want out of it. For example:

#if DLEVEL > 5
    #define SIGNAL  1
    #if STACKUSE == 1
        #define STACK   200
    #else
        #define STACK   100
    #endif
#else
    #define SIGNAL  0
    #if STACKUSE == 1
        #define STACK   100
    #else
        #define STACK   50
    #endif
#endif
#if DLEVEL == 0
    #define STACK 0
#elif DLEVEL == 1
    #define STACK 100
#elif DLEVEL > 5
    display( debugptr );
#else
    #define STACK 200
#endif

Includes defining an expression evaluator if I want to tackle it. This has to be a solved problem! If you have Vim suggestions or other ones please let me know.

Edit
Report

2 Answers

1

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).

answered 2009-04-11T01:13:26.407
1

Emacs has hide-ifdef-mode (I've never had to use it myself, so I can't vouch for its quality)

answered 2009-04-12T19:42:07.107

Your Answer