c宏函数中的`...`是什么?
what is `...` in c macro function?
你好,我一直在阅读一个 c 库,我遇到过这样的宏函数:
#define TF_LITE_KERNEL_LOG(context, ...) \
do { \
(context)->ReportError((context),__VA_ARGS__); \
} while (false)
我不太明白 ...
作为参数之一的用法。谁能看出它的目的是什么?如果以这样的方式调用函数,它是否用于忽略其他参数? : TF_LITE_KERNEL_LOG(context, arg1, arg2, arg3)
这是可变参数标记:__VA_ARGS__
被替换为提供给宏的其余参数,例如在 printf()
,因此
TF_LITE_KERNEL_LOG(context, arg1, arg2, arg3)
会像:
context->ReportError(context, arg1, arg2, arg3)
.
你好,我一直在阅读一个 c 库,我遇到过这样的宏函数:
#define TF_LITE_KERNEL_LOG(context, ...) \
do { \
(context)->ReportError((context),__VA_ARGS__); \
} while (false)
我不太明白 ...
作为参数之一的用法。谁能看出它的目的是什么?如果以这样的方式调用函数,它是否用于忽略其他参数? : TF_LITE_KERNEL_LOG(context, arg1, arg2, arg3)
这是可变参数标记:__VA_ARGS__
被替换为提供给宏的其余参数,例如在 printf()
,因此
TF_LITE_KERNEL_LOG(context, arg1, arg2, arg3)
会像:
context->ReportError(context, arg1, arg2, arg3)
.