Where to get function definitions of standard libraries?

i want the definitions of functions that we just use by including their header files. Like
strcmp()
gets()
etc...
Last edited on
The definitions of standard library functions are specific to each implementation.

For example, the FreeBSD libc cvs repository is here:
http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/

strcmp.c - http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/string/strcmp.c
gets.c - http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/stdio/gets.c
Look under these for the branch of interest.

I'm using windows if that's what you mean by implementation.
The C standard describes the C header files and what you should expect to see in them, and similarly the C++ standard describes C++ header files.

In addition to that, each operating system has it's own set of header files for its own functions. To complicate things further, C and Unix are somewhat intertwined, so there's a lot of duplication between the two systems.

As you're using Windows, I guess you'll need to check the Platform SDK documentation for the full list, it's over 600 functions so be warned. Windows.h pulls in other headers that each define subsets of the SDK. Further more, the Windows API gets larger with each Platform release.

The functions you asked about are from the C standard library, strcmp is defined in string.h and gets is defined in stdio.h.
> I'm using windows if that's what you mean by implementation.

The C++ implementation would be something like:
MSVC 10.0 32-bit (Microsoft Visual C++ Express 2011 32 bit x86 Windows XP)
or: GCC 4.3 32-bit x86 Cygwin.


If your implementation is the Microsoft one, look under
<Visual Studio Install Directory>\VC\crt\src
For instance: <Visual Studio Install Directory>\VC\crt\src\strcmp.c

Note: An implementations may use intrinsics for functions like strcmp(); so you might also want to have a look at the generated assembly code.
thanks JLBorges.
I did find source codes of many functions.
Topic archived. No new replies allowed.