Aesop
Aesop

Reputation: 161

what is `...` in c macro function?

Hi I've been reading through a c library, and I've encountered macro functions such as this:

#define TF_LITE_KERNEL_LOG(context, ...)           \
  do {                                             \  
    (context)->ReportError((context),__VA_ARGS__); \
} while (false)

I don't exactly get the use of ... as one of the parameters. Could anyone see what is it's purpose? Is it used to ignore other arguments if the function is called in a way like this? : TF_LITE_KERNEL_LOG(context, arg1, arg2, arg3)

Upvotes: 1

Views: 106

Answers (1)

Matthieu
Matthieu

Reputation: 3097

It's the variadic arguments marker: the __VA_ARGS__ are replaced with the rest of the arguments given to the macro, like e.g. in printf(), so

TF_LITE_KERNEL_LOG(context, arg1, arg2, arg3) will be like:

context->ReportError(context, arg1, arg2, arg3).

Upvotes: 4

Related Questions