Macros & Directives in C
From the C cheat sheet · Preprocessor · verified Jul 2026
Macros & Directives
#define, #include, and conditional compilation.
c
// Quick Reference
#define MAX 100
#define SQUARE(x) ((x) * (x))
#include <stdio.h>
#ifndef HEADER_H
#define HEADER_H
#endif💡 The preprocessor does pure text substitution before the compiler ever runs.
⚡ Always parenthesize macro parameters and the whole body to avoid precedence bugs.
📌 Guard every header with #ifndef/#define/#endif (or #pragma once) against double include.
🟢 #ifdef DEBUG lets you compile in extra logging only when DEBUG is defined (-DDEBUG).
preprocessormacros