Macro Routines

原创
2015/01/24 10:24
阅读数 91

#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);
}

展开阅读全文
加载中

作者的其它热门文章

打赏
0
0 收藏
分享
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部