#define Directive


Syntax

A preprocessing macro has one of the following two forms.

#define macro_name replacement_list
#define macro_name(identifier,identifer,...identifier) replacement_list

Notes

Examples

Given the simple macro definition

#define size 256

the line

char string[size];

expands as follows.

char string[256];

Given the macro definitions:

#define ten    10
#define twenty 20
 
#define sum(parameterA,parameterB) parameterA + parameterB

the line

sum(ten,twenty)

expands as shown below.

10 + 20

Note that the parameters specified on the call to the function-like macro sum are themselves macros. The actual parameters specified on the call are bound to their formal counterparts. The actual parameters are expanded (being themselves macros) prior to substitution into the macro replacement list.