2 ms·
So, apparently, one cannot even count on C compilers to push arguments from left to right. Right-to-left is pretty much the most sensible way to implement vari
by userbinator 11y ago
So, apparently, one cannot even count on C compilers to push arguments from left to right.
Right-to-left is pretty much the most sensible way to implement variadic functions with a stack-based calling convention - the argument that the function uses to interpret the rest of them must be found at a known location relative to the stack "top", and due to how stacks work, that implies the varying portion has to be pushed first, thus right-to-left.
Maybe if C decided to design things a little differently:
int printf(..., const char *format);
...
printf(5, "There are %d lights.\n");
we would instead have right-to-left being the dominant C calling convention.