Course contentsShow
← C
Lesson 795 of 1,21911. The Preprocessor and BuildFree lesson

Standard header search paths

Standard header search paths

What you'll learn: Understanding the difference between how the C compiler locates library headers versus your own custom project files.

When you write #include <stdio.h>, you are telling the C preprocessor to go find a file. But your computer has millions of files; how does the compiler know exactly where that specific one is hidden? It follows a very specific "postal route" called the search path.

Angle brackets vs. Double quotes

The way you wrap the filename tells the compiler where to start its journey:

  1. Angle Brackets <filename.h>: These are for Standard Headers. The compiler looks exclusively in "System Folders"—pre-defined directories on your hard drive where C libraries are installed (like /usr/include on Linux). It assumes these files are part of the language environment or external libraries you’ve installed.
  2. Double Quotes "filename.h": These are for User Headers. The compiler starts by looking in the current directory (where your .c file lives). If it can't find the file there, it then falls back to the system folders.

The "Local Shop" analogy

Think of your source code like a kitchen. If you need "Salt" (a standard ingredient), you don't look in your own pockets; you go straight to the Pantry (the System Path). You use <salt.h>.

If you need a "Secret Sauce" you just made, you look on your Countertop (the Current Directory) first. You use "secret_sauce.h". If it’s not there, you might check the Pantry just in case, but you always check your workspace first.

A visual example

// Looking in system directories only
// Path: /usr/include/stdio.h
#include <stdio.h> 

// Looking in the project folder first, then system directories
// Path: ./my_settings.h
#include "my_settings.h"

int main() {
    printf("Standard headers use brackets; local ones use quotes.\n");
    return 0;
}

Why does this matter?

Using the wrong syntax can lead to "File not found" errors, even if the file exists. If you try to include your own file with <my_file.h>, the compiler will skip your project folder entirely and search only the system libraries, failing to find your code. By using the correct symbols, you guide the compiler to the right starting point, making the build process faster and more predictable.

Key takeaway

Use < > for built-in libraries and " " for files you created in your project folder.