I'm not much of a C programmer, but I was under the assumption that C macros were almost sort of a find and replace feature where the pre-processor takes the macro definition and puts it wherever it sees the macro name.
This is the Dragon Book's example of dynamic scope rules and how they apply to macros:
#define a (x + 1)
int x = 2;
void b () { int x = 1; printf("%d\n", a); }
void c () { printf("%d\n", a); }
void main () { b(); c(); }
They also discuss how dynamic scope rules apply to the name x within macro a. I was under the assumption that it would basically replace a with (x + 1) and then compile the program and so the scope rules would be exactly the same as if you had written (x + 1) instead of a (which would be static scope rules).
Could anyone clarify this?
Edit: Book referred to is Compilers: Principles, Techniques & Tools Second Edition. The example quoted is from pages 31-32.