Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View default include path of C headers in Mac OS X by `gcc -v`?

Tags:

c++

c

xcode

macos

I tried to find the default include path of the C compiler in Mac OS X (Mavericks) by using gcc -v:

$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix

It seems to tell me the path is /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1, but I'm afraid it is not the true path. I think the true path for including standard C library is /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include because <sys/syscall.h> locates in the later path, which is /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/sys/syscall.h

Does anyone have ideas about how to view all the default include path of C library in Mac OS X?

like image 416
Hanfei Sun Avatar asked Nov 08 '13 05:11

Hanfei Sun


People also ask

Where is my gcc path Mac?

Homebrew by default installs gcc to /opt/homebrew/bin . There you will be able to find gcc-11 . You can also find this path by running which gcc-11 .

Where are C header files on Mac?

sdk . From there, usr/include holds common public headers such as the standard C headers, and various Apple headers are in frameworks under System . In /Applications/Xcode. app/Contents/Developer/Platforms , you will likely find folders for other platforms, such as iPhoneOS.


1 Answers

You need to ask the preprocessor, not gcc, for telling the default include path.

You can say:

`gcc -print-prog-name=cc1` -v

In order to list default include path for both C and C++:

`gcc -print-prog-name=cc1plus` -v

(The path that you've listed above is the one that was used to configure GCC while building.)


Another way to list the default include path would be:

gcc -x c -v -E /dev/null

gcc -x c++ -v -E /dev/null     # (for C/C++)
like image 95
devnull Avatar answered Sep 29 '22 14:09

devnull