样式检查。错误:开放括号'('前需要空格。

问题描述 投票:1回答:1

我有一个C++宏,它看起来像下面。

#define UTRACE_WRITE(trace_fd, ...)     do { if (trace_fd >= 0) this->trace_write (trace_fd, __VA_ARGS__); } while(0);

风格检查程序checkpatch.pl通过一个错误,如下所示

ERROR: space required before the open parenthesis '('

如何克服上述错误,而不是使用 /*IGNORE_STYLE_CHECK*/?

另外,我的样式检查代码给';'的警告,如果我忽略这个,将来会有什么问题?

WARNING: do {} while (0) macros should not be semicolon terminated
c++ c coding-style lint
1个回答
0
投票

我很喜欢答案,所以在这里。

#define UTRACE_WRITE(trace_fd, ...)     do { if (trace_fd >= 0) this->trace_write (trace_fd, __VA_ARGS__); } while (0)

在括号前加个空格: while (0)

并去掉最后的小括号后的分号。

© www.soinside.com 2019 - 2024. All rights reserved.