October 2004
Beginner
408 pages
9h 24m
English
Macros created by the #define directive are named snippets of code. For constants, the name reflects a literal value. On a more complex level, you can also assign actions (executed statements or logical chunks) to a macro, creating a function-like macro:
#define ALERT printf("Danger!")
With this directive, uses of ALERT in your C code will be replaced with that printf() statement.
As always, there is a catch here: C preprocessor directives must be defined on a single line. Once a new line is encountered, the old directive's definition is over. When the information for a directive won't fit on a single line (which is most likely to happen with function-like macros), you can break up the line by inserting a space followed ...
Read now
Unlock full access