"Jon Berndt" <[EMAIL PROTECTED]> writes:

> I ran into this problem when looking through FlightGear code in the past.
> It's hard to keep track of things like:
>
> #ifdef xxx
>  200 lines of code
> #else
>  100 lines of code
> #endif

If you happen to be using Emacs (available on Windows, the various derivatives
of Unix/Linux, and for other environments as well), you can eliminate the
viewing of the not-in-use code by typing "M-x hide-ifdef-mode" followed (if
necessary, depending on your configuration) by "M-x hide-ifdefs".  To show the
whole thing again, you can do "M-x show-ifdefs"

This will change code with ifdefs like this:

    #include <stdio.h>

    int main(int argc, char * argv[])
    {
    #ifdef xxx
      /*
       * Lots of code here
       * which is only used
       * in the rare case
       * that 'xxx' is actually
       * defined.
       */
    #else
      /*
       * The real code is here
       * and this is all we
       * normally really want
       * to see.
       */
    #endif
    }

into this:

    #include <stdio.h>

    int main(int argc, char * argv[])
    {
    #ifdef xxx ...
    #else
      /*
       * The real code is here
       * and this is all we
       * normally really want
       * to see.
       */
    #endif
    }

Yup, it actually runs a C preprocessor to determine what should be displayed,
so you get the proper stuff displayed.  There are options available for
setting "C preprocessor" defines that would be specified at compile time, in
case not all of the defines are in header files.

Enjoy.

Derrell

_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to