Calling funcs from a var arg function 
Author Message
 Calling funcs from a var arg function

I've got a question about functions that receive a variable number of
arguments.  Particularly, is it always safe to call another function from
such a function?

The examples in 'The C Programming Language (2nd Ed)' call other function
after the call to va_start().  I would also assume it is safe to call other
functions after the call to va_end().  However, is it safe to call another
function before the call to va_start()?

Thanks...



Tue, 19 Dec 1995 18:33:06 GMT  
 Calling funcs from a var arg function

Quote:

>I've got a question about functions that receive a variable number of
>arguments.  Particularly, is it always safe to call another function from
>such a function?
>The examples in 'The C Programming Language (2nd Ed)' call other function
>after the call to va_start().  I would also assume it is safe to call other
>functions after the call to va_end().  However, is it safe to call another
>function before the call to va_start()?
>Thanks...

IT should be... usually. The stack pointer will be at the top of the
stack when the variable argument function is called, and the stack frame
for the next function will get plunked on top of it. There should be no
reason for any of the va_ functions to be called to maintain stack
integrity. Please not the large number of "shoulds" in this paragraph...
(well, critically placed shoulds anyway) ... I see no reason why it
wouldn't work, but if you get memory errors or mysterious crashes, that
would be a suspect. But, why not call va_start? It doesn't really affect
the function call after all (unless you never return, but that's a special
case in and of itself)
                --Chris Amshey

--



(Woe is me, I have a limit of 4 lines to my .signature file! Misery!)



Thu, 28 Dec 1995 15:17:45 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Numerical recipes, var arg function passing - how to?

2. unsigned short as var arg

3. Yet another var-arg problem...

4. Any error in this code (var arg problem)

5. Calling MFC funcs in Extension DLL?

6. arg c, arg[v] in borland turbo c 4.5

7. # of args in a variable arg call

8. CONFLICT - Global Var of a .LIB Vs Global Var of a program which uses the LIB

9. how to call C++ func(int &var) from C.

10. var = !var;

11. Condition breakpoints and function calls and function calls in Immediate window

12. extern var vs. static extern var

 

 
Powered by phpBB® Forum Software