Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!ll-xn!mit-eddie!uw-beaver!golde From: golde@uw-beaver.UUCP (Helmut Golde) Newsgroups: comp.lang.c Subject: Re: Problem with either ANSI 'C' or Dr Dobbs Journal. Message-ID: <2144@uw-beaver.UUCP> Date: Thu, 6-Aug-87 02:59:59 EDT Article-I.D.: uw-beave.2144 Posted: Thu Aug 6 02:59:59 1987 Date-Received: Sat, 8-Aug-87 08:59:12 EDT References: <449@sugar.UUCP> Reply-To: golde@uw-beaver.UUCP (Helmut Golde) Organization: U of Washington, Computer Science, Seattle Lines: 36 In article <449@sugar.UUCP> peter@sugar.UUCP (Peter da Silva) writes: >According to an article on ANSI 'C' in Dr Dobb's Journal, a prototype >with a fixed number of arguments means the routine may be called without >unwinding the stack on return... the assumption being that the called >routine popped its arguments with a "RET N" type instruction. > >It then adds that if no prototype is provided, the function may be >assumed to have a fixed number of arguments. This is correct, but the key word in the paragraph is "may". Probably most compilers will continue to do things the old way, with the same calling conventions for fixed length and variable length argument lists. However, on some machines it is much more efficient to to use a calling sequence which only supports fixed length variable lists, so this is why ANSI allows different calling sequences for fixed and variable length argument lists. The moral (and ANSI makes this very clear): all calls to functions which take a variable number of arguments must be made in the presence of a prototype. Your program is *non-portable* otherwise. In general, you are just plain dumb if you write any program in which *any* function calls are made without an applicable prototype or include file. They don't take much time to put in, they may make your program run faster, and you're sure to save debugging time. (I think almost every program over 300 lines I have written I have been saved from a type screw-up by prototypes). >I don't know if there's an answer... perhaps this could be made an optional >and defeatable extension? It *is* optional, as I stated above. Some compilers may even have a switch which allows you to do it both ways (Microsoft C for example). Obviously in such a case a provision must be made that a different library will be used or that library calls are always made the same way regardless of the switch. --Peter ]