[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Using m4 between the C preprocessor and compiler?
From: |
Raphaël “Kena” Poss |
Subject: |
Using m4 between the C preprocessor and compiler? |
Date: |
Fri, 3 Jul 2009 15:37:42 +0200 |
Dear all,
as part of a project I am looking for ways to perform context-
insensitive but parameterized substitutions on C code. It happens
that m4 delivers well for what I need to do. Except for the following.
For now I have used m4 as a front-end before running the C
preprocessor and compiler. The downside of this is that I can only
substitute on the "main" source provided to m4, not to the code
inlined by the C preprocessor through #include.
The other way around (using m4 after the C preprocessor) mostly works,
but then m4 does not recognize the location markers (#line) inserted
by the preprocessor and therefore most m4 errors are reported at an
incorrect location, and multi-line expansions cause m4 to use wrong
relative numbers in new synclines.
On top of this main issue, I would be interested to disable m4 macro
expansion within C strings and comments; although I already thought
about (yet another) filter between CPP and m4 to m4-quote all C
strings and comments.
Do you have any suggestions on how to solve the #line-problem and more
elegantly the string/comment problem?
I tried a possible route forward by replacing any occurrence of "#line
X" in the m4 input by m4_define(`__line__', X), but unfortunately that
doesn't seem to help. Is there an option to allow __line__ (and
__file__) to be reset by macros?
Comments would be highly appreciated.
--
Raphaël “kena” Poss address@hidden - +31 20 525 7898
Computer Systems Architecture http://www.science.uva.nl/research/csa/
Informatics Institute http://www.science.uva.nl/ii/
Universiteit van Amsterdam http://www.english.uva.nl/
- Using m4 between the C preprocessor and compiler?,
Raphaël “Kena” Poss <=