1

Shouldn't I be getting warning or error message after declaring macro in this way:

#define c 123
#define a b
#define b c

The code worked flawlessly - so just like variable definition, is macro definition stored somewhere?

1 Answer 1

1

This is perfectly fine, because preprocessor does not act upon macro definitions until the point of expansion. That is why the order does not matter: as long as each macro has a definition to which it could be expanded when your code makes a reference to it, the preprocessor is happy. This applies to macros that rely on other macros for their expansion.

One consequence of this behavior is that the relative order of macro declarations does not change the end result.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.