|C preprocessor vs Macro processor email@example.com (Peter Govoni) (1997-11-02)|
|Re: C preprocessor vs Macro processor firstname.lastname@example.org (Greg Badros) (1997-11-07)|
|Re: C preprocessor vs Macro processor email@example.com (1997-11-11)|
|Re: C preprocessor vs Macro processor firstname.lastname@example.org (1997-11-13)|
|From:||Greg Badros <email@example.com>|
|Date:||7 Nov 1997 00:47:43 -0500|
|Organization:||Computer Science, U of Washington, Seattle, WA, USA|
Peter Govoni <firstname.lastname@example.org> writes:
> Could someone please explain why a macro processor (e.g. M4)
> is 1) more powerful than the C preprocessor and
M4 allows rearranging code too. e.g., you can have a macro that takes
part of its arguments and writes them out to a diverted channel, and
then later output that previously-hidden channel. Cpp allows only
local expansion of macros.
Also, M4 has many many more builtin functions (including regular
expression matching, and much more) and permits recursive macros; Ansi
C's cpp disallows recursion in macros.
M4 also permits a macro's expansion to include a newline; cpp cannot
(hence the imake hack of replacing @@ w/ newlines after the
preprocessor has run).
> 2) more suitable for assembly languages
Perhaps because M4 is more powerful; you can build more infrastructure
more easily w/ M4, raising the level of abstraction more easily --
something assembly truly benefits from.
> Does the C preprocessor hold any advantage over M4 ?
It's easier to learn, is not stuck with complicated quoting rules, and
more constrained in its capabilities; reasoning about source code
preprocessed by cpp is hard enough -- reasoning about source code
processed by m4 would be nearly impossible.
Greg J. Badros
Seattle, WA USA
Return to the
Search the comp.compilers archives again.