Skip to content

Instantly share code, notes, and snippets.

@colematt
Created October 3, 2023 01:57
Show Gist options
  • Save colematt/6131fc6b79587b39e0338931655e2d0c to your computer and use it in GitHub Desktop.
Save colematt/6131fc6b79587b39e0338931655e2d0c to your computer and use it in GitHub Desktop.
Where Does the C/C++ Compiler Find Header Files?

Where does the C/C++ Compiler Find Header Files?

Ask the Preprocessor

GNU

# GNU C++ preprocessor
`gcc -print-prog-name=cc1plus` -v
# GNU C preprocessor
`gcc -print-prog-name=cpp` -v

Clang

# C
clang -H hello.c
# CPP
clang++ -H hello.cpp

Ask the Compiler

# C
gcc -v hello.c
clang -### hello.c
# C++
gcc++ -### hello.cpp
clang++ -### hello.cpp

Read the Manual

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment