When are macros expanded?

Henry Spencer henry at utzoo.uucp
Fri Feb 2 08:21:29 AEST 1990


In article <6458 at stealth.acf.nyu.edu> brnstnd at stealth.acf.nyu.edu (Dan Bernstein) writes:
>Is the preprocessor allowed to expand macros inside #defines? If it does
>so uniformly, then ANSI's rule about recursive macros is easy to enforce
>and implement, but certain tricks aren't possible. (Maybe this is a good
>thing.) Does ANSI say anything about this? What's the ``best'' behavior?

ANSI in general has pinned down the semantics of preprocessing much more
precisely than before, although this particular question was (somewhat
vaguely) addressed even by K&R1.  Expansion of "inner" macros happens at 
invocation time, not at definition time.

Implementing the recursion rule is a pain, actually.
-- 
1972: Saturn V #15 flight-ready|     Henry Spencer at U of Toronto Zoology
1990: birds nesting in engines | uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.lang.c mailing list