Macro Routines

The Entire Macro Expression Enclosed in Parentheses

#define Cube(a) aaa # Cube(x+1) –> x+1x+1x+1
#define Cube(a) (a)(a)(a) # 10/Cube(x+1) –> 10/(x+1)(x+1)(x+1)
#define Cube(a) ((a)(a)(a)) # 10/Cube(x+1) –> 10/((x+1)(x+1)(x+1))

The Macro Contains Multiple Statements with Braces

#define LookupEntry(key, index) \

index = (key - 10) / 5;        \
index = min(index, MAX_INDEX); \
index = max(index, MIN_INDEX);

–>

for (entryCount = 0; entryCount < numEntries; entryCount++)

LookupEntry(entryCount, tableIndex[entryCount]);

#define LookupEntry(key, index) \

{                                  \
    index = (key - 10) / 5;        \
    index = min(index, MAX_INDEX); \
    index = max(index, MIN_INDEX); \
}

你可能感兴趣的:(Macro Routines)