Markus Forrer

Problems with vprintf, va_start, va_end

Discussion created by Markus Forrer on Jun 19, 2012
Latest reply on Jun 28, 2012 by Markus Forrer

Hello

 

I have implemented a function to output debug messages to rs232 and/or sd-card (MC9S12XDP512):

 

void WriteMonitor(char *theString, ...)

{

  va_list theArguments;

  set_printf(PutChar);

  va_start(theArguments, theString);

  (void)vprintf(theString, theArguments);

  va_end(theArguments);

}

 

static void PutChar(char theChar)

{

  SciDriverSendChar(theChar);

}

 

Sometimes I'll get illegal characters on the debug result (special characters and more characters the expected).

 

Second problem: I'll get compiler warning C5917 (removed dead assignment) on the line 'va_end(theArguments)'.

 

Any hints?

 

Thanks a lot!

Marc

Outcomes