We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
hello,
i needed to do a wrapper for printf. was working in c but i though it would be nicer to have it in a class with some other functions along. the problem is the Keil (when --cpp flag is set) won't understand the va_start/end and it shows this error "error: used of undeclared identifier" when the --cpp is set in project options. but Keil compiles the code, but the only effect is there is a memory leak and such code froze.
i'm noob and don't know where to look for solution and my google tricks failed this time.
may you please help?
thanks nej.
class UsartConsole { // constructor // destructor ///... /// // echo void echo( const char *str ) { while( *str ) { while( USART_GetFlagStatus( usart, USART_FLAG_TXE) == RESET ); USART_SendData( usart, *str ); str++; } } // printf void printf( const char *format, ... ) { va_list args; if( buf != 0 ) { va_start( args, format ); if( vsnprintf( buf, PRINT_BUFFER_SIZE * sizeof( char ), format, args ) > 0 ) { echo( buf ); } else { echo( buf ); echo( "usart_printf: maxlen \ character limit was reached or some other error, \ such as an invalid format specification\n" ); } va_end( args ); } } // class end };
Any use of std:: anywhere to specify namespace?