Skip to content
QunL edited this page Dec 2, 2013 · 1 revision

PRE30-CPP. 不要使用连接操作来创建一个通用字符名

PRE30-CPP. Do not create a universal character name through concatenation

例如:

#define assign(uc1, uc2, val) uc1##uc2 = val;

int \u0401;

assign( \u04, 01, 4);

建议不要使用通用字符作为内部命名。

#PRE31-CPP. 避免不安全宏参数的负效应

PRE31-CPP. Avoid side-effects in arguments to unsafe macros

不安全的宏指的是测试参数值超过一次或者一次也不测试。 负效应指的是参数中包含赋值、自加、自减、函数调用等。

例如:

#define ABS(x) (((x) < 0) ? -(x) : (x))

/* ... */

m = ABS(++n); /* undefined behavior */

Clone this wiki locally