C library source code [closed]
开发者_StackOverflow
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 1 year ago.
Improve this questionI want to find the C libraries' source code to find out more about the functions used.Is GCC the only resource I can count on?I couldn't use the doxygen html version of the GCC libraries,to tell the truth it seems complex to me,for example I couldn't find the printf function's source code(Was I looking in the wrong place?). Thanks in advance.
OTOH, in addition to glibc:
- uclibc
- dietlibc
- BSD libc
Reading the source code is one thing. Reading a good book that includes source code is another thing entirely. And I'm not sure you can do better than The Standard C Library, by PJ Plauger. It's 20 years old, but for me it's still a page-turner.
Man, I feel old.
The GNU version is here:
Info: http://www.gnu.org/software/libc/
Download: http://ftp.gnu.org/gnu/glibc/
You may need to narrow down your question a bit. The implementation varies. Not everything related to implementation details (perhaps pretty much all of it - someone with more standard knowledge can chip in) is prescribed by the C/C++ standard.
In the end you may understand how a particular library decided to do it. It's still useful knowledge, but not THE answer.
The simplest and cleanest standard C library I've ever seen is Minix's standard library.
I ported it on at least 3 toolchains with virtually no effort.
I actually grew up with that library.
I couldn't find the
printf
function's source code
Here is the source code for this function, it seems to be calling to __vbprintf_internal
, which is found glibc/stdio-common/vfprintf-internal.c
. Glibc
source code is also available in bootlin
, I think it is more readable and convenient code.
int __printf (const char *format, ...)
{
va_list arg;
int done;
va_start (arg, format);
done = __vfprintf_internal (stdout, format, arg, 0);
va_end (arg);
return done;
}
glibc/stdio-common/printf.c
精彩评论