C preprocessor for humans

Alan J Rosenthal flaps at dgp.toronto.edu
Mon Aug 28 07:57:39 AEST 1989


amull at Morgan.COM (Andrew P. Mullhaupt) writes:
>Can anyone recommend a filter through which I can run a source
>program devised by a brilliant hieroglyphist with an over-active
>macro imagination, utter disregard for indentation, and a penchant
>for constructions of questionable portability? 

Re macros:
If you remove #include instructions (and any other macros you *don't* want
de-macro-ified), then run it through the preprocessor alone, then re-add the
#include instructions, you should be able to solve the macro problem.  There is
usually some compiler option to run your source through the preprocessor
alone.  It is often -E.  (If you don't remove the #include instructions, the
macros in the include files will get expanded as well, which you don't want.)
You may find lines beginning with "# " inserted into your file, which you can
delete with a global command in an editor.

Re indentation:
There are a variety of formatters, mostly bizarre.  The most common opinion
among C wizards seems to be that formatters are not generally a good thing.
I agree with that sentiment, but have found formatters useful for unravelling
bizarre code.  The one I use for such purposes is indent.  Indent is bizarre,
but not as bizarre as some of the more hacky C programs out there, so sometimes
it's an improvement.  Probably all unix systems have cb, but that doesn't do as
much.  However, it does set every line to the correct indentation, which may be
all you need.  Outside of unix, I'm not aware of any C formatters, but I'm sure
they must exist.  Some editors probably do C formatting for you, especially on
the ibm-pc, due to the trend in software development on that machine.

Re questionable portability:
The reason that most unportable constructs are unportable is because of unclear
semantics.  To ask a computer to improve on this is asking a bit much, like
mind reading or something.  To merely identify questionable constructs, use
lint.  There is a version of lint for the ibm-pc, commercially available from
somewhere or other.  All unix systems (that I've heard of) have lint.
Alternatively, find a C interpreter, which provides facilities which are
similar in concept but often quite different in practice.

ajr



More information about the Comp.lang.c mailing list