When dealing with variable argument lists in C, I was just curious to know which data structure might a compiler be using when storing the variable arguments in a list.
- Is it an array of void pointers?
- Is it a linked list of void pointers?
- or anything else?
No structure. The calling code just puts the arguments on the stack, it’s the vararg function’s responsibity to decode them properly.
For example in case of printf, the first argument is fixed, a c string, and the rest is decoded based on what’s in the string. C just gives you tools to access these elements so you don’t have to do stack pointer arithmetic based on size of the fields (which is architecture dependent..)