Site Tools


c-header-guard

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
c-header-guard [August 22, 2026 at 17:24] Ivan Janevskic-header-guard [August 22, 2026 at 17:24] (current) Ivan Janevski
Line 1: Line 1:
 # C Header guard # C Header guard
  
-**[Header guard](https://en.cppreference.com/w/c/preprocessor/conditional)** is a C/C++ pattern that prevents multiple inclusion of the same header file by wrapping declarations in preprocessor conditionals. The pattern uses `#ifndef`, `#define`, and `#endif` to ensure declarations are processed only once, even if the header is included multiple times. Modern alternative: [[c-pragma-once|#pragma once]].+**[Header guard](https://en.cppreference.com/w/c/preprocessor/conditional)** is a C/C++ pattern that prevents multiple inclusion of the same header file by wrapping declarations in preprocessor conditionals. The pattern uses `#ifndef`, `#define`, and `#endif` to ensure declarations are processed only once, even if the header is included multiple times. 
 + 
 +Modern alternative: [[c-pragma-once|#pragma once]].
  
 Use header guards to protect against duplicate declarations and multiple definition errors. Use header guards to protect against duplicate declarations and multiple definition errors.
c-header-guard.md · Last modified: by Ivan Janevski