From mboxrd@z Thu Jan 1 00:00:00 1970 To: 9fans@cse.psu.edu From: "Douglas A. Gwyn" Message-ID: <3D9A13FE.E52C05F8@null.net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit References: <821f6979e86cb87e2f87d83def62d004@vitanuova.com> Subject: Re: [9fans] function inconsistently declared Date: Wed, 2 Oct 2002 09:01:36 +0000 Topicbox-Message-UUID: faf164e0-eaca-11e9-9e20-41e7f4b1d025 C H Forsyth wrote: > in old C, > f(a, b) > int a; > char b; > { > ... > } > actual parameters for b were always promoted to int > (since prototypes weren't available, and the compiler didn't maintain a > file of the types of parameters to internal and external functions, it > had to assume int for char, double for float etc.) Actually it didn't *have* to, but it was convenient for the way PDP-11 function linkage worked. In the presence of a prototype, it is quite possible for the compiler to use a linkage that differs from the one used for unprototyped functions. In this regard also remember that use of a variable-argument function requires that the ,...) prototype be visible; quite a few systems use a linkage for that situation that is different from the one for unprototyped functions. I still occasionally have to fix up some legacy code like: error("foo %d\n",1); /* no prototype in scope */ error("punt\n"); ... void error(char *fmt, int x) { ... something involving &x }