]> git.ozlabs.org Git - ccan/commitdiff
cppmagic: Allow multiple and deferred evaluation
authorDavid Gibson <david@gibson.dropbear.id.au>
Tue, 26 Jan 2016 10:32:07 +0000 (21:32 +1100)
committerDavid Gibson <david@gibson.dropbear.id.au>
Wed, 3 Feb 2016 22:44:13 +0000 (09:44 +1100)
Recursion (and therefore iteration) in cpp is difficult, since the
preprocessor explicitly looks for and inhibits recursion.

But, it's possible to trick it, up to a point.  CPPMAGIC_DEFER1() and
CPPMAGIC_DEFER2() can "hide" a macro, preventing it from being expanded
and being noticed as recursion.

Along with that we need to cause extra expansion passes to be executed.
There has to be a finite limit here - true recursion is impossible - but
that number can be made very large pretty easily.  CPPMAGIC_EVAL() multiply
expands its argument(s) - up to 1024 times.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

No differences found