From mboxrd@z Thu Jan 1 00:00:00 1970 To: 9fans@cse.psu.edu Subject: Re: [9fans] calling function with (variable number of) parameters From: rog@vitanuova.com MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Message-Id: <20010621142423.D9AFF199EB@mail.cse.psu.edu> Date: Thu, 21 Jun 2001 15:33:15 +0100 Topicbox-Message-UUID: be9c0b22-eac9-11e9-9e20-41e7f4b1d025 > So save space for n + 1 parameters on the stack; the last won't be used > by your called function, and you could store the number of parameters in > it. When you return, pop the last item off the stack, and use that to > recalculate the frame pointer. no actually, parameters are pushed on last first, so the last one you've pushed (the one you've got access after the return) is the first parameter to the function (which doesn't expect it). i think that probably the only way of getting around the problem is to change the prototype of the called function so that the first parameter signifies the number of parameters. the only other alternative is if the function is guaranteed to be non-reentrant (fat chance) in which case you could store the number of params in a static variable. of course, that then makes it incompatible with the original... cheers, rog.