使用宏時須注意:
- 參數(shù)兩邊要加括號
- 整個表達式兩邊要加括號
- 特別注意表達式多次求值的情況,如 max(++i, j)
- 宏會攪亂名字空間
- 宏不能遞歸
- 宏沒有地址
- 宏不利于調試
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/