使用do{ } while(0)的好处
看到过一些程序中或者宏中使用do{} while (0)觉得挺奇怪,不知道为什么这么写,就百度了一下...
看到一个比较好的帖子,给大家分享下!
我遇见的宏#define AB1 a; b; // x, 下面语句b不能被执行: if (cond) AB1;#define AB2 { a; b; } // x, 下面语句编译出错:if (cond) AB2; else ...;#define AB3 a, b // x, 有运算符优先级问题#define AB4 do { a; b; } while (0)