header-guard
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| header-guard [May 14, 2026 at 12:59] – yanevskiv | header-guard [May 14, 2026 at 13:01] (current) – yanevskiv | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| # Header guard | # Header guard | ||
| - | **Header guards** are a pattern used in C and C++ programming languages when writing header files. Header files (.h files) are files that are included in source files (.c and .cpp files) using the `#include < | + | **Header guards** are a pattern used in C and C++ programming languages when writing header files. Header files (.h files) are files that are included in source files (.c and .cpp files) near the top (hence the name) using the `#include < |
| - | Header guards follow the same general pattern. | + | Header guards follow the same general pattern: |
| ```c | ```c | ||
| #ifndef __HEADER_GUARD_H__ | #ifndef __HEADER_GUARD_H__ | ||
| Line 9: | Line 9: | ||
| // ... | // ... | ||
| - | #endif | + | # |
| ``` | ``` | ||
| Line 28: | Line 28: | ||
| ``` | ``` | ||
| - | ### Why? | + | This allows multiple inclusion of " |
| ```c | ```c | ||
| // main.c | // main.c | ||
| Line 39: | Line 39: | ||
| } | } | ||
| ``` | ``` | ||
| + | |||
header-guard.1778763550.txt.gz · Last modified: by yanevskiv
