C Programming • C17 baseline, standards-specific features labeled
Headers, Includes, and the Preprocessor
Share declarations through guarded headers and keep macros simple and side-effect free.
The preprocessor handles directives before compilation. A header guard prevents a header from being processed repeatedly in one translation unit. Prefer typed functions or enum constants over function-like macros when they provide the same behavior.
Example
#ifndef POINT_H
#define POINT_H
struct point {
double x;
double y;
};
#endif
What to expect
Including point.h declares struct point once per translation unit.
Key idea: Headers should expose declarations; keep ordinary function implementations in source files.