Eclipse CDT- 转到#define 语句中的下一行
Eclipse CDT- go to next line in #define statement
我在 Eclipse-CDT 中工作,我有以下 #define 语句:
#define IS_ARGUMENT_NULL(arg) if (NULL == arg) {fprintf(stderr, "%s is NULL", #arg); bool isNull = true;}
该行对我来说太长了(我需要保持每行最多 80 个字符),我想知道我怎样才能通过代码下一行来编译 ok。
我尝试按回车键并获得
#define IS_ARGUMENT_NULL(arg) if (NULL == arg) {fprintf(stderr, "%s is NULL", #arg);
bool isNull = true;}
但它无法编译。第二行说 "expected identifier or ‘(’ before ‘}’ token"
反斜杠(\
)是换行符。
#define IS_ARGUMENT_NULL(arg) \
if (NULL == arg) { \
fprintf(stderr, "%s is NULL", #arg); \
bool isNull = true; \
}
来自gcc manual:
The macro's body ends at the end of the ‘#define’ line. You may
continue the definition onto multiple lines, if necessary, using
backslash-newline. When the macro is expanded, however, it will all
come out on one line.
我在 Eclipse-CDT 中工作,我有以下 #define 语句:
#define IS_ARGUMENT_NULL(arg) if (NULL == arg) {fprintf(stderr, "%s is NULL", #arg); bool isNull = true;}
该行对我来说太长了(我需要保持每行最多 80 个字符),我想知道我怎样才能通过代码下一行来编译 ok。 我尝试按回车键并获得
#define IS_ARGUMENT_NULL(arg) if (NULL == arg) {fprintf(stderr, "%s is NULL", #arg);
bool isNull = true;}
但它无法编译。第二行说 "expected identifier or ‘(’ before ‘}’ token"
反斜杠(\
)是换行符。
#define IS_ARGUMENT_NULL(arg) \
if (NULL == arg) { \
fprintf(stderr, "%s is NULL", #arg); \
bool isNull = true; \
}
来自gcc manual:
The macro's body ends at the end of the ‘#define’ line. You may continue the definition onto multiple lines, if necessary, using backslash-newline. When the macro is expanded, however, it will all come out on one line.