28

I'm looking for the whole source code of all the C standard libraries. That said, I'm looking for the source code of stdio.h, stdlib.h, string.h, math.h, etc... I would like to see how they were created. I think that it depends from platform to platform, but Linux or Windows one will be welcomed.

CoffeeRain
  • 4,460
  • 4
  • 31
  • 50
  • Do you want the header files (stdio.h) or the source code for the .lib and .dll files that implement the header files? – Steve Rowe Mar 12 '12 at 17:48
  • 5
    The .h files are not "the whole source code of all the C standard libraries", they're just the headers. So which is it you actually want? The header files come with your C implementation, but the definitions of the functions themselves may not be available to you if your C implementation is not open source. Even when they are available they might not be very instructive on their own, since in some cases a standard library function just calls an OS function to do all the work. – Steve Jessop Mar 12 '12 at 17:48
  • 4
    You probably want the GNU Libc http://www.gnu.org/software/libc/ – Basile Starynkevitch Mar 12 '12 at 17:50

4 Answers4

24

If you want the actual implementations, as everyone else has assumed you don't, many Linux distributions currently use glibc to implement the C standard library. Common alternatives include musl libc, diet libc, uClibc, and Bionic

Phil Miller
  • 36,389
  • 13
  • 67
  • 90
  • 1
    uClibc says its releases are on hold, and one should use uClibc-ng https://uclibc-ng.org/ – flavio Mar 20 '19 at 18:43
11

PJ Plauger wrote a book about the standard C library. Includes references from the (now dated) standard, and source code.

Mike Sherrill 'Cat Recall'
  • 91,602
  • 17
  • 122
  • 185
3

Microsoft Visual Studio generally has the system headers under <InstallDir>\VC\include, and the source, if installed, is under <InstallDir>\VC\crt\src.

AShelly
  • 34,686
  • 15
  • 91
  • 152
-3

Whether its installed with an IDE or you have installed explicitly, you have to look in the directory "Include" in respective location.

Ex: I use MinGW. So, I would go to

c:/MinGW/include to find those header files. Similarly, for an IDE (say Dev-cpp), you need to go to c:/dev-cpp/include.

Surya
  • 4,824
  • 6
  • 38
  • 63