The difference between standard C preprocessor and Lisp macros is that
Lisp allows you to
use Lisp itself to perform the transformations, therefore giving much
more power to the
programmer.
I'm looking for a macro language/preprocessor for C that gives me the
power of C to preprocess C programs. In practice, this would mean that
the compiler/preprocessor would have to include a C interpreter and
facilities for generating and analyzing C constructs.
I've never seen this done in C (which isn't proof of nonexistence).
(IME) the prevailing/popular practice in C when you want more than the
standard preprocessor gives is *separate* tools that generate C source
-- either general-purpose like awk and perl (both somewhat C-like but
not totally) or special-purpose like IDL (RPC) compilers, embedded-SQL
mappers, autoconf, etc. C-pp does have #line and #file directives to
help such separate tools be more transparent.
perl does have eval; (standard/common) awk doesn't, but it can invoke
itself as a child process which gives the same power more clumsily.
None of the tools I know has parsing that would handle full C as
input; they do sometimes use C *style* for more limited input.
These kinds of techniques handle a LOT of useful cases. But if you
need (or want) complete generality -- any bounded manipulation of any
representable program -- I can't help you.
FWIW, PL/I (I believe standardly) has a preprocessor with syntax
slightly tweaked (mostly adding some percent signs) and (quite!)
subset semantics (but still useful). And, inevitably, suffered from
the unresolvable debates between 'heavy preprocessing can much better
express the problem domain' and 'heavy preprocessing makes it too
difficult to understand what the actual code is'.