location of library function code

Dec 30, 2010 at 12:13am
Hello
I'm programing in ANSI C and i'd like to know if there is a way to view the code of the library funtions (like strlen, malloc, strcmpr etc.)
Is there a systematic way to find a specific funtion?
How does the runtime know where to find the definition of a specific function?
Thanks in advance

Dec 30, 2010 at 4:57am
There is a way to view the code of the specific library functions, yes! How to do this varies between systems, unfortunately.

A systematic way to find a specific function... what do you mean by this?

C and C++ executables are linked with a library containing the code, which in some cases is a glorified copy-and-paste of the function's binary code done at compile-time, and in other cases an addition of a bit of code at compile time that dynamically loads this data from a library in some predefined location. This is of course a simplification, but I think you get the idea. :)

-Albatross
Jan 2, 2011 at 5:27pm
If by "Systematic Way" you're looking for a VBS wbemtest equivalent in C or C++ then no. But if you're just looking to read the code then they are stored as plain text files with your compiler\IDE. This is not an easy task though as most of the files are linked with more files which link to even more files... You're better off reading here: http://www.cplusplus.com/reference/ until you get the hang of it.
Jan 2, 2011 at 5:47pm
It would help knowing which OS you are running on, and whether you are using an IDE such as eclipse.

I'm on Linux, and when I need to check up on the implementation of system functions, I simply download the source code and read it. Sometimes it is rather challenging to locate the right function, when many exists with the same name.

The source downloading is most easily handled with the packaging program that comes with your specific Linux flavour. Let me know if you want more information about this.
Topic archived. No new replies allowed.