Skye Huang Skye Huang - 4 months ago 7
C Question

Where to find C source code on mac?

I was looking through a programming textbook and saw a particular header i didn't recognize. Later I looked it up on the internet but I was wondering where the source code of C can be found on a macbook. Is it just in the compiler? (I use gcc) Please help.

Answer

The source code to much of the OS/X operating system and utilities, including the C library can be found at http://opensource.apple.com/ .

The source for the current version of the C library is here: http://opensource.apple.com/source/Libc/Libc-1082.50.1/ .

For other packages installed via brew or macports, use the corresponding command to retrieve the source for the packages. Look at the man page to see how.

Note that the gcc command actually runs clang on recent versions of XCode under OS/X. Try gcc --version...