pre-processing

Sukru Cinar <scinar@ug.bcc.bilkent.edu.tr>
9 Apr 1999 14:16:24 -0400

          From comp.compilers

Related articles
pre-processing scinar@ug.bcc.bilkent.edu.tr (Sukru Cinar) (1999-04-09)
| List of all articles for this month |

From: Sukru Cinar <scinar@ug.bcc.bilkent.edu.tr>
Newsgroups: comp.compilers
Date: 9 Apr 1999 14:16:24 -0400
Organization: Bilkent University
Keywords: macros, question

Hello, I Have Recently Been Working On A Cpp-Like Preprocessor. But I Have
A Problem With Recursively Defined Macros. Such As


#define N N+5


I see that cpp doesn't expand these kinds of recursive expressions more
than once. the problem is, if you expand the text only once, than you
cannot use expressions including macro invocations as parameters to a
macro. this is pretty ugly. the preprocessor looses most of its
functionality. if you allow expansion of strings every time after a macro
expansion occurs, then the infinite loop thing emerges. checking all the
strings that are result of an expansion against a recursion seems to me
costly.( what if the recursion is a deep one ? )


Does anybody have an idea about a good solution to this? Is this situation
worth considering? I Mean, Are There Any Real Life Cases That Recursive
Macros May Be Useful?


Thanx For Any Help.
[In a weak macro language like cpp without conditional macro expansion
recursion isn't useful because it always is an infinite explosion. In a
more complete macro language like TCL or Trac, recursive macros are
very useful because that's how you do macro-time iteration. -John]



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.