#define st(x) do { x } while (__LINE__ == -1)

#define st(x)      do { x } while (__LINE__ == -1)

1, __LINE__ 是个宏,它代表当前代码在源文件的行号,它是大于0的,所以__LINE__ == -1 等同于0,化简为:
#define st(x) do { x } while (0)

2,do {} while (0)通常用于宏中, 为的是避免如下情况:

#define st(x) x

那么我们在调用 if (0) st(a = b; b = c;) 时会被解释成

if(0)
a = b;
b = c;

可见 if 只对a = b;起作用。

猜你喜欢

转载自blog.csdn.net/z_hualin/article/details/79023967