V
vib
Hi there,
I am looking at this code for quite awhile, still don't any clue why
one wants to do it this way. It is about display message through UART
or COM port. Here is the code.
The calling code:
[1] MyDbgPrintf(("File Write Error\n"));
The called code:
[2] #define MyDbgPrintf(x) UART_Printf x
MOre, the body of UART_Printf:
[3]
void UART_Printf( const char *fmt, ... )
{
v_list ap;
char string[1024];
if( gUart_init == TRUE )
{
v_start( ap, fmt );
vsprintf( string, fmt, ap );
UART_SendString( string );
v_end( ap );
}
}
And the
[3]
void UART_SendString(char *string )
{
if( gUart_init == TRUE )
{
while( *string )
UART_SendByte( *string++ );
}
}
[4]
typedef int *v_list[1];
[5]
#define v_start(ap, parmN) (void)(*(ap) = __va_start(parmN))
[6]
#define v_end(ap) ((void)(*(ap) = 0))
Any comments?
what are [4], [5] [6] and why?
Thanks in advance.
I am looking at this code for quite awhile, still don't any clue why
one wants to do it this way. It is about display message through UART
or COM port. Here is the code.
The calling code:
[1] MyDbgPrintf(("File Write Error\n"));
The called code:
[2] #define MyDbgPrintf(x) UART_Printf x
MOre, the body of UART_Printf:
[3]
void UART_Printf( const char *fmt, ... )
{
v_list ap;
char string[1024];
if( gUart_init == TRUE )
{
v_start( ap, fmt );
vsprintf( string, fmt, ap );
UART_SendString( string );
v_end( ap );
}
}
And the
[3]
void UART_SendString(char *string )
{
if( gUart_init == TRUE )
{
while( *string )
UART_SendByte( *string++ );
}
}
[4]
typedef int *v_list[1];
[5]
#define v_start(ap, parmN) (void)(*(ap) = __va_start(parmN))
[6]
#define v_end(ap) ((void)(*(ap) = 0))
Any comments?
what are [4], [5] [6] and why?
Thanks in advance.