3 ms·
Varargs was not part of the language originally. If you look at the source code for printf() from Unix v7, I think you'll find it accesses its arguments by inde
by dn3500 6y ago
Varargs was not part of the language originally. If you look at the source code for printf() from Unix v7, I think you'll find it accesses its arguments by indexing off the address of the first one. I don't remember when varargs came along, but it was some time in the 1980s, and this book was written in 1990.
Which is not to excuse the author. His description of how this works and why you would want to do it is just wrong.
- _kst_ 6y agoA particular implementation of printf used that technique. There probably weren't a whole lot of different implementations at the time, but it's not part of the C specification. <varargs.h> was a pre-Standard header that provided a consistent interface for accessing variable arguments. It was superseded by <stdarg.h> in the 1989 ANSI C standard. gcc in particular dropped support for <varargs.h> a number of years ago.