2007年4月24日火曜日

printf()補足

Mac OS Xのprintf()のソースコードをhttp://developer.apple.com/macosx/からDownload(Libc-391.5.21)してきて,除いてみた.
すると,stdio/FreeBSD/printf.cに実装があった.中身は

int
printf(char const * __restrict fmt, ...)
{
int ret;
va_list ap;

va_start(ap, fmt);
ret = vfprintf(stdout, fmt, ap);
va_end(ap);
return (ret);
}

となっており,単にvfprintf()のwrapperのようだ..

1 件のコメント:

rdv さんのコメント...

All very good.

You can also, on some OSes, step *into* the library or stub routine for printf or write using the debugger and stepping one instruction at a time.

Score: 10/10