1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

This is definitely not what we want
REMEMBER that macros are pure text
replacement they are not function calls-

  • Lack of care will cause nasty problems


For example, cube(a++)expands in the following way:


(a++)*(a++)*(a++)


This computes the correct value for the cube, but the new
value of a will be:
a+3
after this expression and not a+1 as we might expect


A number of the standard library procedures, like getchar
and putchar are really macros and not procedures -

*

this saves the overhead of doing a procedure call

March 3, 1998

Page 3

C201/TAM