how to check c standard library function source code in eclipse

Thor Source

I'm currently learning c and want to know how a standard library function is implemented e.g.

enter image description here

I control clicked on the fgets function and it took me to the function prototype declaration of fgets in stdio.h header file.

enter image description here

But I want to see how fgets is implemented, not its function prototype. Is there anyway to see its internal implementation?

ceclipse

Answers

answered 5 days ago TypeIA #1

The source code for some standard library implementations, such as glibc, are available online, and you can look up its fgets() code. But the source code isn't typically installed on a development PC unless you're building your own toolchain for some reason (e.g., a cross-compiler). In fact, portions of the source code are often written in assembly. Only the compiled object files are usually installed on development / target PCs. Therefore, your IDE doesn't have access to the source and can't show it to you. Other standard libraries like Microsoft's MSVCRT are proprietary and the source code is not available, only the compiled library. You can always disassemble that of course, but the output is not likely to be very useful to you.

In general most (not all!) C/C++ programmers treat standard library functions as black boxes and rely on good reference documentation to understand their behavior.

comments powered by Disqus