【发布时间】:2022-01-17 13:25:02
【问题描述】:
在 C 程序(u-boot)中,为了检查程序是否运行该宏,我更改了定义状态
来自
#define debug_cond(cond, fmt, args...) \
({ \
if (cond) \
log(LOG_CATEGORY, \
(enum log_level_t)(LOGL_FORCE_DEBUG | _LOG_DEBUG), \
fmt, ##args); \
})
到
#define debug_cond(cond, fmt, args...) \
({ \
extern uint64_t myptr; \
if (cond) { \
*((uint64_t *)myptr) = 0x801; myptr+=8; \
log(LOG_CATEGORY, \
(enum log_level_t)(LOGL_FORCE_DEBUG | _LOG_DEBUG), \
fmt, ##args); \
}
}) <==== line 267
编译器给了我这个错误信息。
In file included from include/linux/printk.h:4,
from include/common.h:20,
from lib/asm-offsets.c:14:
include/log.h:267:1: error: expected identifier or '(' before '}' token
267 | })
| ^
include/log.h:267:2: error: expected identifier or '(' before ')' token
267 | })
我不知道这里出了什么问题。谁能告诉我哪里做错了?
【问题讨论】:
-
您是否检查过宏中的所有行都有 line-continuation 转义?
-
啊,是的,第 266 行最后没有
line continuation。写一个简单的答案,以便我可以选择它。
标签: c compiler-errors c-preprocessor