3 ms·
Incidentally, the codebase I'm looking at right now contains gems like this: /*VARARGS2*/ int margin_printf (fp, a, b, c, d, e, f, g) FILE *fp;
by david-given 10y ago
Incidentally, the codebase I'm looking at right now contains gems like this:
/*VARARGS2*/
int margin_printf (fp, a, b, c, d, e, f, g)
FILE *fp;
char *a;
long b, c, d, e, f, g;
{
ind_printf (0, fp, a, b, c, d, e, f, g);
} /* margin_printf */
Called (from a different source file) like this:
margin_printf (outfile, length ? "/* %s */\n" : "\n", storage);
Okay, so that's K&R C, and it's not actually compiled any more (because I've been slowly taking this stuff out and replacing it with things that actually work), but still --- the horror, the horror...
- caf 10y agoThat kind of hackery was necessary because K&R C didn't give you any sanctioned way to write your own printf-like functions. ANSI C introduced <stdarg.h>.
- david-given 10y agoSure. Also, K&R C tended to target platforms with really simple ABIs, where parameters were always passed on the stack and everything was a machine word; so you could get away with this kind of thing. K&R C actually has a minimalist elegance to it that later versions of C lost. Not that I'm claiming that it's better, of course. But K&R C had a distinct philosophy to it that was definitely its own.