Tag Archives: How to Search in Header File

C Language: How to Search in Header File (Two Methods)

angle bracket pattern

Header files enclosed by angle brackets, for example #include <file>, are searched from standard system directories by default, and the exact search path depends on the target system, how GCC is configured, and where GCC is installed. cpp -vThe default search path can be viewed through the directive.

quote pattern

Header files enclosed in quotes, for example #include "file", are searched first from the current file’s directory, and then from the standard system directories.

Specify the search directory

With -Idircommand line options, you can specify a custom search directory.

For quote mode, after the current directory is searched, the directory specified by dir will be searched, and finally the standard system directory will be searched.

For angle bracket mode, the directory specified by dir is searched first, followed by the standard system directories.

More granular control over search directories

If you want to specify only the search path for quote patterns, you can use -iquotethis option. This option only applies to quote patterns. -I,-isystem,-idirafterApplies to both.