on-internet
← Community

Why is the macro name not excluded from expansion ("painted blue")?

Stack Overflow ·

Say I have the following two macro definitions: #define foo(X) 1 bar #define bar(X) 2 foo Why does foo(X)(Y)(Z) expand to 1 2 1 bar? According to the C99 standard 6.10.3.4 Rescanning and further replacement If the name of the macro being replaced is found during this scan of the replacement list (not including the rest of the source file’s preprocessing tokens), it is not replaced. Furthermore, if any nested replacements encounter the name of the macro being replaced, it is not replaced. These nonreplaced macro name preprocessing tokens are no longer available for further replacement even if t

Comments

Sign in or sign up to comment and upvote.

No comments yet.