使用宏時(shí)須注意:
- 參數(shù)兩邊要加括號(hào)
- 整個(gè)表達(dá)式兩邊要加括號(hào)
- 特別注意表達(dá)式多次求值的情況,如 max(++i, j)
- 宏會(huì)攪亂名字空間
- 宏不能遞歸
- 宏沒有地址
- 宏不利于調(diào)試
On a compliant compiler, it is not possible for a macro to create any of the following:
a trigraph (trigraphs are replaced in phase 1);
a universal character name (\uXXXX, replaced in phase 1);
an end-of-line line-splicing backslash (replaced in phase 2);
a comment (replaced in phase 3);
another macro or preprocessing directive (expanded and executed in phase 4); or
changes to a character literal (for example, 'x') or string literal (for example, "hello, world") via macro names inside the strings.
文章來源:
http://my.donews.com/robinchow/2007/02/11/bavcdirqeacybkdedpxorhuddpwyehtghojl/