This is probably a very simple and core component of C programming but it's extremely hard to search for
printk in the kernel can take a number of log level consts and the function itself uses varargs, however I can't figure out why it works. Here's an example call for those not familiar
printk(KERN_DEBUG "this is my message which can be %s as normal", "formatted");
The source code is below and it uses varargs but what mechanism allows to pass multiple strings that are space-separated to one parameter?
asmlinkage __visible int printk(const char *fmt, ...)
{
va_list args;
int r;
va_start(args, fmt);
r = vprintk_func(fmt, args);
va_end(args);
return r;
}
This isn't particular to printk, I've seen it used in drivers in the kernel when creating a device
device_create(drv_class,
NULL,
dev,
NULL,
MY_DEVICE_NAME "%d", i);
Can anyone tell me what allows this? Is it compiler specific or a core part of the language?