Void fun1 (int a,... );
Void fun2 (int, b... );
How to call in the fun1 func2?
The original ideas naive
Void fun1 (int a,... )
{
Fun2 (a,... );
}
O action!!!!!!
CodePudding user response:
# define debug_printf (FMT,... ) printf (FMT, # # __VA_ARGS__)
CodePudding user response:
@ stherix
, I am not function to define macro
I mean is:
# define FUNC (A,... Func1 (A, # # __VA_ARGS__)
Func1 need to uncertain parameters are passed to the function func2
Macro definition written
# define FUNC (A,... Func2 (A, # # __VA_ARGS__) is not very convenient
So want to transfer at a time
CodePudding user response:
refer to the second floor also didn't want to good XP response: @ stherix , I am not function to define macro I mean is: # define FUNC (A,... Func1 (A, # # __VA_ARGS__) Func1 need to uncertain parameters are passed to the function func2 Macro definition written # define FUNC (A,... Func2 (A, # # __VA_ARGS__) is not very convenient So want to be a transfer If you want to transfer function is (... ) the parameter Should be can't do it CodePudding user response:
Stdarg. H Check to know CodePudding user response:
Can only use macros, not directly between function calls CodePudding user response:
C + +, uncertain parameter template can be done, CodePudding user response:
Va_list CodePudding user response:
Void fun1 (int a,... ) { Va_list args. Va_start (args, a);//get fun1 uncertain parameter list Fun2 (a, args);//will fun1 uncertain parameter list as a parameter to the fun2, } Void fun2 (int a,... ) { Va_list fun2_args; Va_start (a, fun2_args);//get fun2 uncertain parameter list Va_list fun1_args; Fun1_args=va_arg (fun2_args va_list);//by fun2 indefinite reference list to fun1 uncertain parameter list Int a=va_arg (fun1_args, int);//parsing fun1 uncertain parameters of the A: printf (" % d ", a);//print parameter } Fun1 (1, 10); //output is 10; //this is feasible, I've tested, but doing so or not reasonable, I'm not sure, if you look at don't understand the words to say again, CodePudding user response:
Pointer to the variable parameter function can't as function arguments?