Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site alice.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!alice!ark From: ark@alice.UUCP (Andrew Koenig) Newsgroups: net.lang.c Subject: Re: varargs.h Message-ID: <3424@alice.UUCP> Date: Mon, 25-Feb-85 19:28:24 EST Article-I.D.: alice.3424 Posted: Mon Feb 25 19:28:24 1985 Date-Received: Wed, 27-Feb-85 08:35:44 EST References: <148@ISM780B.UUCP> Organization: Bell Labs, Murray Hill Lines: 33 >>As the author of varargs, I would like to set the record straight. >> >>The intention of varargs was that the type given to va_arg >>should only be a type that is meaningful as a parameter. Thus >>char, short, and float are never meaningful because they >>are automatically widened to int, int, and double respectively. >There is nothing in the language that says that parameters cannot be >declared as char, short, or float. And if typeof is (should be!) >added to the language, this will become all the more important. >Since sizeof is a compile-time constant, there is no reason why >va_arg cannot widen appropriately via ?: . Of course, you will want an >ifdef lint version to avoid all the "constant used in a conditional context" >messages. And speaking of lint, someone should fix it so it does not do >type checking against VARARGS parameters (or maybe we need a /*VARTYPE*/ >comment?) >-- Jim Balter, INTERACTIVE Systems (ima!jim) Ummm -- my mistake. I meant argument, not parameter. Char and short arguments are automatically cast to ints. Float arguments are automatically cast to doubles. Thus there is no reason to use anything as the second argument to va_arg except the wide types. Yes, varargs could be changed to recognize the lengths of the narrow types -- on some machines. However, consider a machine where int and float have the same size. Anyway, even if you did manage to change varargs, all that would do is encourage people to write "portable" programs that would only run on the new version. Best leave it as it is. --Andrew Koenig