Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!brutus.cs.uiuc.edu!psuvax1!husc6!spdcc!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: Macro Substitution too Complex? Keywords: macros Message-ID: <16621@haddock.ima.isc.com> Date: 6 May 90 03:17:49 GMT References: <1990May5.014816.26452@agate.berkeley.edu> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Distribution: usa Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 24 In article <1990May5.014816.26452@agate.berkeley.edu> c60c-2ca@WEB.berkeley.edu (Andrew Choi) writes: >Hi everyone. I thought I understood how macro substituion >works, until I came up with the following example: ... Since the example uses the `##' operator, we're talking about ANSI C here. >One possible explanation is that macro substitution is not recursive. You got it. It's normally pretty useless for macro substitution to be done recursively, since there's no way for it to bottom out (the preprocessor sublanguage lacks a conditional that can be executed within a macro), so it was decreed to be nonrecursive (so one can write `#define char signed char', for example). >However, is this a standard behavior? Yes, this sort of behavior is required for a conforming implementation. >Does anyone know the "standard" rules for performing macro substitution? I would guess that very few people know them completely; I'm not one of them. There are some rather subtle issues involved; see the examples in the ANS. Karl W. Z. Heuer (karl@ima.ima.isc.com or harvard!ima!karl), The Walking Lint