Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!decwrl!labrea!agate!pasteur!ames!umd5!ncifcrf!nlm-mcs!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: Variadic argument functions Message-ID: <7698@brl-smoke.ARPA> Date: 15 Apr 88 21:49:33 GMT References: <1238@wjvax.UUCP> <297@ho7cad.ATT.COM> <1242@wjvax.UUCP> <7667@brl-smoke.ARPA> <253@teletron.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 26 In article <253@teletron.UUCP> andrew@teletron.UUCP (Andrew Scott) writes: > (*vector)(arg); > void funcA(arg) > void funcB() For maximal portability, your functions all need to have identical interfaces, either precisely the same number and types of arguments and return value, or all variadic arguments (in which case there must still be at least one fixed "anchor" argument of the same type). On a large number of architectures, though, you can get away with your current approach. >in the range 0..1000. Should the argument be of type short, to emphasize the >range of the argument? Or, should I use ints everywhere and simply document >the range of acceptable argument values. How about function return values? The main reason most existing functions use int is that that was the type to which all smaller integral types were widened at the function interface. This widening is not required for ANSI C when prototypes are used. The best style would be to use the appropriate type AND document the interface. The safest thing to do is to use int anyway, because some compilers may incorrectly handle other function definitions (they aren't supposed to mishandle these, but it's been known to happen).