Problems with vprintf, va_start, va_end

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Problems with vprintf, va_start, va_end

1,365件の閲覧回数
mark99
Contributor I

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

ラベル(1)
0 件の賞賛
返信
2 返答(返信)

910件の閲覧回数
kef
Specialist I
  • Sometimes I'll get illegal characters on the debug result (special characters and more
  • characters the expected).

Maybe you have baudrate mismatch? Also you should make sure you have enough stack space. 

 

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

va_end macro clears theArguments pointer. Of cause this assignment is not used in your code and thus is dead. You may disable compiler warning adding this line somewhere above the va_end line :

#pragma MESSAGE DISABLE C5917

0 件の賞賛
返信

910件の閲覧回数
mark99
Contributor I

Thank you for the answer!

 

It's no baudrate mismatch, because I have the same problem writing on a SD card. Unfortunately it's not a problem with stack space.

 

Very tricky...

0 件の賞賛
返信