Do you use stdarg, varargs or ya-args?

Don Libes libes at cme.nist.gov
Fri May 10 14:24:41 AEST 1991


All the STDC (-like) compilers I use support varargs.  (To be
explicit, this includes Borland, DEC, GNU, and Microsoft compilers.)
All the non-STDC compilers I use (too many to name) support varargs.

Naturally, the non-STDC compilers don't support stdarg.

The obvious question is: why bother using stdarg?  Is any vendor
really going to omit varargs 5 or even 10 years from now?  I seriously
doubt it.  (I'm betting one of my coworkers money on this.)  I suppose
that eventually one may have to explicitly use some flag when
compiling (say "-varargs"), but don't you think the support will
always be provided by the vendor somehow?  (All the STDC compilers
already provide a shitload of extensions.)

Yes, programs that use varargs are not conforming, but we (and I'm
speaking strictly for my coworkers here) are trying for maximal
portability in unknown environments.  Either there is a curious irony
here or I don't understand why STDC invented stdarg.  (Admittedly,
some non-STDC compilers don't even support varargs.)

Some of my coworkers use 1) only stdargs, 2) only varargs, or 3) both
with ifdefs to select between them.  Other possibilities are 4) a macro
package to cover-up the choice, 5) avoid entirely, and 6) you don't
know what I'm talking about and pass everything as if it were an int.

(1) This makes sense to me if you are writing for and only for a STDC
environment.  Otherwise it just doesn't fly in the real world.
(3) Ghastly to read and write.
(4) Code doesn't look like STDC, and it raises the question of the
original point of the invention of stdarg if it's never actually used
directly.  Unfortunately, there ain't no way to make the STDC macros
work on top a varargs implementation.  Even worse, how do you explain
to a new C programmer that they shouldn't use what's in STDC?

Obviously, I think people who subscribe to (3) or (4) are misguided.

Don Libes          libes at cme.nist.gov      ...!uunet!cme-durer!libes



More information about the Comp.lang.c mailing list