Include Guards
Prevent double inclusion.
The Double-Include Problem
Headers often include other headers. It is easy for one header to end up included twice in the same source file.
When that happens, every declaration in it appears twice. For type definitions like struct or typedef, that is a compile error: a type cannot be defined more than once.
How It Sneaks In
Suppose a.h and b.h both include types.h. A source file that includes both ends up with types.h pasted in twice.
The preprocessor blindly copies header text, so types.h's definitions duplicate, triggering a redefinition error.
/* a.h */ #include "types.h"
/* b.h */ #include "types.h"
/* main.c */
#include "a.h"
#include "b.h" /* types.h now seen twice */