P. 1
Programming with lcc-win32

Programming with lcc-win32

5.0

|Views: 683|Likes:
Published by Jeff Pratt

More info:

Published by: Jeff Pratt on Sep 08, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

05/09/2014

pdf

text

original

1) One of the most common errors is to add a semi colon after the macro:

#define add(a,b) a+b;

When expanded, this macro will add a semicolon into the text, with the consequence of a
cascade of syntax errors with apparently no reason.

A closer look at the pre-processor 163

2) Watch for side effects within macros. A macro invocation is similar to a function call, with
the big difference that the arguments of the function call is evaluated once but in the macro
can be evaluated several times. For instance we have the macro “square”

#define square(a) (a*a)

If we use it like this:

b = square(a++);

After expansion this will be converted into:

b = (a++)*(a++);

and the variable a will be incremented twice.

164 C programming with lcc-win32

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->