var args

Henry Spencer henry at utzoo.UUCP
Sat Oct 22 07:51:13 AEST 1983


I'm not so much *objecting* to the machine-dependent nature of
variable-length-arg-list routines, as trying to point out that
their implementation *is* fundamentally machine-dependent and
there is *no* *way* *around* *this*.  This is in response to
numerous people proposing one notion after another of how to do
something that simply cannot be done.  Worse, some of their schemes
do work on *some* machines, and people who don't understand the
messiness of the issue might assume that they work everywhere.
I've had enough encounters with unportable software as a result of
such assumptions to think it worthwhile to try to head this particular
problem off.

Yes, I'm aware of the library packages under 4BSD and System V that
try to at least bury the machine-dependencies in a library.  Be warned
that even they don't suffice on sufficiently bizarre machines.

The most common reason for wanting vararg routines other than the
standard ones is a desire to write an error-handling routine that
puts out a printf-style message and then does some program-dependent
cleanup actions.  The *only* 100% portable way to do this is:

	sprintf(buf, ".....", ....);
	error(buf);

I know it's a nuisance to do two calls instead of one, and the need
to have a buffer variable is annoying, but this code is guaranteed
to be fairly portable, while using %r, _doprnt, &args, etc. is not.
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,linus,decvax}!utzoo!henry



More information about the Comp.lang.c mailing list