函数参数的传递原理
函数参数是以数据结构:栈的形式存取,从右至左入栈。
-
VOID Nguhyw_printf(const char *fmt, ...)
-
{
-
va_list args;
-
int length;
-
char log_buf[CFG_CONSOLEBUF_SIZE];
-
-
va_start(args, fmt);
-
/* the return value of vsnprintf is the number of bytes that would be
-
* written to buffer had if the size of the buffer been sufficiently
-
* large excluding the terminating null byte. If the output string
-
* would be larger than the log_buf, we have to adjust the output
-
* length. */
-
length = vsnprintf(log_buf, sizeof(log_buf) - 1, fmt, args);
-
if (length > CFG_CONSOLEBUF_SIZE - 1)
-
length = CFG_CONSOLEBUF_SIZE - 1;
-
-
uart_write(log_buf, length);
-
va_end(args);
-
}
阅读(2566) | 评论(0) | 转发(0) |