I'm working on my own implementation of the standard C library function printf. I am currently trying to add the (non-standard) behaviour for when the notation specifies an argument number ($).
In this case, if you supply 5 arguments and only argument 1, 2 3 and 5 are referenced in the format string, since the arguments are stored in a list obtained with va_start, I have a problem. To get to argument 5, I'll have to skip argument 4. This means I'll have to call va_arg on argument 4. That means I have to specify a type for argument 4, which I don't have any information about.
My question is: what data type does printf use in this situation? Or if that is unknown, what type would you use? I have tried void but va_arg doesn't accept it as a data type (which kind of makes sense). I know all of this is undefined behaviour but I'm trying to work out how printf handles it so any ideas are welcome!
$-based syntax is not from Standard C — it's a Single UNIX Specification extension. - Ruslan