c++ - Pass Variable arguments from function to another with variable arguments -
i have following function shouldn't change not break dependencies
void  trace(         __in dbginfo dbginfo,         __in_z _printf_format_string_ const wchar* pwszmsgformat,         ...) {              // code need          };     i need call function has ... args:
#define trace_line(     format, ... ) _trace( loglevelinfo ,format, __va_args__ )  #define _trace( mask, format, ... )  \         ((mask) & g_loglevel)              \             ? traceglobal::traceline( mask, l"[" __filew__ l":" _blob_wide(_blob_stringize(__line__)) l"] "  l"myservice!" __functionw__ l": " format , __va_args__ ) \             : (void)0  void servicetracing::traceglobal::traceline(     _in_            loglevel level,     _in_z_          pcwstr format,     _in_            ...) /** routine description:      trace formatted line level tracing  arguments:      level: enum level of trace line     format: string format     ...: variable arguments formatted  return value:      none **/ {     assert(format);      va_list args;     va_start(args, format);      // code tracing      va_end(args);  }   how can that?
inside main trace function above tried this:
trace_line( pwszmsgformat, __va_args__ );   this didn't work , got error:
 syntax error : missing ')' before identifier 'pwszmsgformat'  error c2059: syntax error : ')'   i assuming because macro __va_args__ gives error.
on other hand tried calling traceglobal directly
va_list args; va_start(args, pwszmsgformat); traceglobal::traceline(loglevelinfo, pwszmsgformat , args ); va_end(args);   this builds fine segmentation fault / access violation in tracing function because initialize va_list , use va_start in traceline
is there simple way can pass along variable arguments function another. don't want change trace function macro.
 
 
  
Comments
Post a Comment