C Programming Preprocessors and Macros 11 mins read 22,806 views

C Preprocessor Directives: How Source Code Is Prepared Before Compilation

Here's something surprising about C that most people learn late: the first thing that happens to your source file isn't compilation. It's a separate, simpler pa...
Published: Nov 1, 2026Last Updated: Nov 21, 2026Curriculum: Class 12 / AP Physics / JEE-NEETReviewed by: OperateTools Editorial Board
Quick Summary & Direct Answer (AEO / GEO Extraction)

What is C Preprocessor Directives: How Source Code Is Prepared Before Compilation? Here's something surprising about C that most people learn late: the first thing that happens to your source file isn't compilation. It's a separate, simpler pa...

Audience & Scope: Students, educators, and candidates preparing for academic examinations and technical assessments in C Programming.
What is the C preprocessor, and how do directives starting with `#` perform textual transformation before the compiler executes?
<p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">Here's something surprising about C that most people learn late: <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">the first thing that happens to your source file isn't compilation.</span> It's a separate, simpler pass called the <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">preprocessor</span>, and what it does is nothing like compiling. It doesn't understand types. It doesn't understand scope. It doesn't understand your functions or your variables.</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">It edits text.</span></p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))]" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="block" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); display: block;"><span class="text-[var(--sdm-c,inherit)] dark:text-[var(--shiki-dark,var(--sdm-c,inherit))] bg-[var(--sdm-tbg)] dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background-color: rgba(0, 0, 0, 0); color: rgb(252, 252, 253); --sdm-c: inherit; --sdm-tbg: transparent;">#define MAX 100</span></span><span class="block" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); display: block;"><span class="text-[var(--sdm-c,inherit)] dark:text-[var(--shiki-dark,var(--sdm-c,inherit))] bg-[var(--sdm-tbg)] dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background-color: rgba(0, 0, 0, 0); color: rgb(252, 252, 253); --sdm-c: inherit; --sdm-tbg: transparent;">int arr[MAX];</span></span></code></pre></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">Before the compiler ever sees this, the preprocessor has already turned it into:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))]" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="block" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); display: block;"><span class="text-[var(--sdm-c,inherit)] dark:text-[var(--shiki-dark,var(--sdm-c,inherit))] bg-[var(--sdm-tbg)] dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background-color: rgba(0, 0, 0, 0); color: rgb(252, 252, 253); --sdm-c: inherit; --sdm-tbg: transparent;">int arr[100];</span></span></code></pre></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">The <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#define</code> line is <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">gone</span> — consumed by the preprocessor — and every <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">MAX</code> in the rest of the file has been <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">textually replaced</span> with <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">100</code>. The compiler never knows a macro existed.</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">That's the whole model, and it explains almost every preprocessor behavior you'll ever be confused by: why macro arguments get evaluated twice, why a missing parenthesis causes catastrophic bugs, why <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#include</code> is nothing like an import statement, and why the same header included twice can break your build.</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><em style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);">(Suggested image: the hero graphic — a source file passing through a labeled "preprocessor" box, with <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#define MAX 100</code> disappearing and <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">arr[MAX]</code> becoming <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">arr[100]</code> on the way out)</em></p>

Explanation & In-Depth Details

<h2 class="mt-6 mb-2 font-semibold text-2xl" data-streamdown="heading-2" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1.125rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.105469px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);">The Build Pipeline: Where the Preprocessor Fits</h2><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="" data-language="" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"> <span class="js-id">main</span><span class="js-op">.</span><span class="js-id">c</span> │ ▼ ┌──────────────────┐ │ <span class="js-id">PREPROCESSOR</span> │ #<span class="js-id">include</span> <span class="js-id">spliced</span> <span class="js-kw">in</span><span class="js-op">,</span> #<span class="js-id">define</span> <span class="js-id">substituted</span><span class="js-op">,</span> │ <span class="js-op">(</span><span class="js-id">text</span> <span class="js-id">handling</span><span class="js-op">)</span> │ <span class="js-id">conditionals</span> <span class="js-id">resolved</span><span class="js-op">,</span> <span class="js-id">comments</span> <span class="js-id">removed</span> └──────────────────┘ │ ▼ <span class="js-id">main</span><span class="js-op">.</span><span class="js-id">i</span> ← <span class="js-id">the</span> <span class="js-str">"translation unit"</span> — <span class="js-id">pure</span> <span class="js-id">C</span><span class="js-op">,</span> <span class="js-id">no</span> <span class="js-id">directives</span> <span class="js-id">left</span> │ ▼ ┌──────────────────┐ │ <span class="js-id">COMPILER</span> │ <span class="js-id">parses</span> <span class="js-id">and</span> <span class="js-id">type</span><span class="js-op">-</span><span class="js-id">checks</span> <span class="js-id">real</span> <span class="js-id">C</span><span class="js-op">,</span> <span class="js-id">emits</span> <span class="js-id">assembly</span> └──────────────────┘ │ ▼ <span class="js-id">main</span><span class="js-op">.</span><span class="js-id">s</span> │ ▼ ┌──────────────────┐ │ <span class="js-id">ASSEMBLER</span> │ └──────────────────┘ │ ▼ <span class="js-id">main</span><span class="js-op">.</span><span class="js-id">o</span> │ ▼ ┌──────────────────┐ │ <span class="js-id">LINKER</span> │ <span class="js-id">combines</span> <span class="js-op">.</span><span class="js-id">o</span> <span class="js-id">files</span> <span class="js-id">and</span> <span class="js-id">libraries</span> └──────────────────┘ │ ▼ <span class="js-id">a</span><span class="js-op">.</span><span class="js-id">out</span> <span class="js-op">/</span> <span class="js-id">a</span><span class="js-op">.</span><span class="js-id">exe</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Every line beginning with <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#</code> is a directive, and it is handled entirely in that first stage.</span> By the time the compiler runs, there are no directives left — the output is ordinary C.</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">You can watch this happen.</span> The command-line option <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">-E</code> runs only the preprocessor:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="bash" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-bash" data-language="bash" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-bash bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-id">gcc</span> <span class="js-op">-</span><span class="js-id">E</span> <span class="js-id">main</span><span class="js-op">.</span><span class="js-id">c</span> <span class="js-op">-</span><span class="js-id">o</span> <span class="js-id">main</span><span class="js-op">.</span><span class="js-id">i</span> # <span class="js-id">preprocess</span> <span class="js-id">only</span><span class="js-op">,</span> <span class="js-id">write</span> <span class="js-id">the</span> <span class="js-id">translation</span> <span class="js-id">unitgcc</span> <span class="js-op">-</span><span class="js-id">E</span> <span class="js-op">-</span><span class="js-id">P</span> <span class="js-id">main</span><span class="js-op">.</span><span class="js-id">c</span> # <span class="js-id">omit</span> <span class="js-id">the</span> #<span class="js-id">line</span> <span class="js-id">markers</span><span class="js-op">,</span> <span class="js-id">cleaner</span> <span class="js-id">to</span> <span class="js-id">readgcc</span> <span class="js-op">-</span><span class="js-id">E</span> <span class="js-op">-</span><span class="js-id">dM</span> <span class="js-id">main</span><span class="js-op">.</span><span class="js-id">c</span> # <span class="js-id">dump</span> <span class="js-id">all</span> <span class="js-id">predefined</span> <span class="js-id">macros</span> <span class="js-id">instead</span> <span class="js-kw">of</span> <span class="js-id">the</span> <span class="js-id">codegcc</span> <span class="js-op">-</span><span class="js-id">E</span> <span class="js-op">-</span><span class="js-id">dD</span> <span class="js-id">main</span><span class="js-op">.</span><span class="js-id">c</span> # <span class="js-id">keep</span> #<span class="js-id">define</span> <span class="js-id">directives</span> <span class="js-kw">in</span> <span class="js-id">the</span> <span class="js-id">output</span> <span class="js-id">too</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">When you're confused about what the preprocessor did, do this.</span> It's the single most effective debugging technique for macro problems — <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">main.i</code> shows you exactly what the compiler is being handed, and macro bugs become obvious when you read it.</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">Two language-level facts that follow from this pipeline:</p><ul class="list-inside list-disc whitespace-normal [li_&amp;]:pl-6" data-streamdown="unordered-list" style="border: 0px solid rgb(47, 47, 55); margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); list-style: outside disc; padding-inline-start: 1.375rem; margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">The preprocessor is line-oriented.</span> A directive runs from <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#</code> to the end of its line. To continue one across multiple lines, end each line with a backslash <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">\</code>.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">main.i</code> is a "translation unit."</span> It's what the compiler actually compiles — a single, self-contained stream of C with everything included and expanded.</li></ul><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><em style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);">(Suggested image: the pipeline drawn as five stages with the preprocessor stage highlighted, and a side panel showing main.c vs main.i side by side)</em></p><hr class="my-6" data-streamdown="horizontal-rule" style="border-width: 1px 0px 0px; border-style: solid; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); height: 0px; margin-block: 1rem 0.75rem; --tw-space-y-reverse: 0; font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><h2 class="mt-6 mb-2 font-semibold text-2xl" data-streamdown="heading-2" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1.125rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.105469px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; letter-spacing: normal; padding: 0.1em 0.35em;">#include</code>: Textual Insertion, Not Import</h2><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#include</code> does the simplest thing imaginable: <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">it opens the file and pastes its entire contents into your source at that point.</span></p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-id">include</span> <span class="js-op">&lt;</span><span class="js-id">stdio</span><span class="js-op">.</span><span class="js-id">h</span><span class="js-op">&gt;</span> <span class="js-cm">/* angle brackets: "system" headers */</span>#<span class="js-id">include</span> <span class="js-str">"myheader.h"</span> <span class="js-cm">/* quotes: "your" headers */</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">The difference between the two forms is the search order:</span></p><div class="my-4 flex flex-col gap-2 rounded-lg bg-sidebar p-2" data-streamdown="table-wrapper" style="border: 0.8px solid rgb(47, 47, 55); margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 0.5rem; margin-block: 1rem 0.75rem; overflow: hidden; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); gap: 0px; --tw-space-y-reverse: 0; display: flex; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px;"><div class="border-collapse" style="border: 1px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); border-collapse: collapse; border-radius: 5.5px; background-color: rgb(18, 18, 22); max-height: 300px;"><table class="w-full divide-y divide-border" data-streamdown="table" style="border-width: 0px; border-color: inherit; margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); text-indent: 0px; min-width: 100%; width: 956.8px;"><thead class="bg-muted/80" data-streamdown="table-header" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0; background-color: oklab(0.252138 0.000131465 -0.00581433 / 0.8);"><tr class="" data-streamdown="table-row" style="border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);"><th class="whitespace-nowrap px-4 py-2 text-left font-semibold text-sm" data-streamdown="table-header-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px; --tw-font-weight: 600; white-space: nowrap;">Form</th><th class="whitespace-nowrap px-4 py-2 text-left font-semibold text-sm" data-streamdown="table-header-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px; --tw-font-weight: 600; white-space: nowrap;">Search order</th></tr></thead><tbody class="divide-y divide-border" data-streamdown="table-body" style="border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);"><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#include &lt;header.h&gt;</code></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Implementation/system include directories only (<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">/usr/include</code>, compiler's own, etc.)</td></tr><tr class="" data-streamdown="table-row" style="border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#include "header.h"</code></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">The directory containing the current file first</span>, then the system directories</td></tr></tbody></table></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">So quotes are for your own project headers, and angle brackets are for library and system headers. Getting them the wrong way round usually still works — until you have a local file that shadows a system header, which is a genuinely confusing bug when it happens.</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">What gets pasted is the whole file, verbatim</span> — including its own <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#include</code> directives, which are then processed recursively, and its own <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#define</code>s, which then apply to everything after the include point. An include is not scoped, not namespaced, and not ordered by dependency. It's textual.</p><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);">The double-inclusion problem</h3><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">Because <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#include</code> is textual, including the same header twice puts its contents in your source twice:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-id">include</span> <span class="js-str">"point.h"</span>#<span class="js-id">include</span> <span class="js-str">"point.h"</span> <span class="js-cm">/* spliced in a second time! */</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">If <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">point.h</code> contains a <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">definition</span> — a <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">typedef</code>, a <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">struct</code>, an enum — the second copy is a duplicate definition:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="" data-language="" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-id">error</span><span class="js-op">:</span> <span class="js-id">redefinition</span> <span class="js-kw">of</span> <span class="js-str">'Point'</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">This is common without anyone writing it twice, because one header includes another that's already included elsewhere.</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Verified demonstration.</span> Preprocessing a file that includes an unguarded header twice produces two copies of the definition:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="" data-language="" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-id">SCENARIO</span> <span class="js-num">1</span><span class="js-op">:</span> <span class="js-id">point</span><span class="js-op">.</span><span class="js-id">h</span> <span class="js-id">with</span> <span class="js-id">NO</span> <span class="js-id">include</span> <span class="js-id">guard</span><span class="js-op">---</span> <span class="js-id">preprocessed</span> <span class="js-id">output</span> <span class="js-op">(</span>#<span class="js-id">include</span> <span class="js-id">spliced</span> <span class="js-kw">in</span><span class="js-op">)</span> <span class="js-op">---</span><span class="js-id">typedef</span> <span class="js-id">struct</span> <span class="js-op">{</span> <span class="js-id">int</span> <span class="js-id">x</span><span class="js-op">,</span> <span class="js-id">y</span><span class="js-op">;</span> <span class="js-op">}</span> <span class="js-id">Point</span><span class="js-op">;</span>

<span class="js-id">typedef</span> <span class="js-id">struct</span> <span class="js-op">{</span> <span class="js-id">int</span> <span class="js-id">x</span><span class="js-op">,</span> <span class="js-id">y</span><span class="js-op">;</span> <span class="js-op">}</span> <span class="js-id">Point</span><span class="js-op">;</span>


<span class="js-id">int</span> <span class="js-id">main</span><span class="js-op">(</span><span class="js-kw">void</span><span class="js-op">)</span> <span class="js-op">{</span> <span class="js-id">Point</span> <span class="js-id">p</span><span class="js-op">;</span> <span class="js-kw">return</span> <span class="js-num">0</span><span class="js-op">;</span> <span class="js-op">}</span>
<span class="js-id">typedef</span><span class="js-op">-</span><span class="js-id">struct</span> <span class="js-id">definitions</span> <span class="js-kw">in</span> <span class="js-id">the</span> <span class="js-id">translation</span> <span class="js-id">unit</span><span class="js-op">:</span> <span class="js-num">2</span><span class="js-op">-&gt;</span> <span class="js-id">redefinition</span> <span class="js-kw">of</span> <span class="js-id">Point</span><span class="js-op">:</span> <span class="js-id">YES</span> <span class="js-op">(</span><span class="js-id">compile</span> <span class="js-id">error</span><span class="js-op">)</span></code></pre></div></div></div><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);">The fix: include guards</h3><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">The standard solution is a wrap of conditional compilation — and note that it works <em style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);">purely</em> through the mechanisms you've just learned: <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#ifndef</code>, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#define</code>, and textual substitution.</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-cm">/* point.h */</span>#<span class="js-id">ifndef</span> <span class="js-id">POINT_H</span> <span class="js-cm">/* if POINT_H is NOT defined... */</span>#<span class="js-id">define</span> <span class="js-id">POINT_H</span> <span class="js-cm">/* ...define it, and process the contents */</span>
<span class="js-id">typedef</span> <span class="js-id">struct</span> <span class="js-op">{</span> <span class="js-id">int</span> <span class="js-id">x</span><span class="js-op">,</span> <span class="js-id">y</span><span class="js-op">;</span> <span class="js-op">}</span> <span class="js-id">Point</span><span class="js-op">;</span>
#<span class="js-id">endif</span> <span class="js-cm">/* POINT_H */</span> <span class="js-cm">/* end of the guarded region */</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Why it works, step by step:</span></p><ol class="list-inside list-decimal whitespace-normal [li_&amp;]:pl-6" data-streamdown="ordered-list" style="border: 0px solid rgb(47, 47, 55); margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); list-style: outside decimal; padding-inline-start: 1.375rem; margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">First inclusion:</span> <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">POINT_H</code> isn't defined, so the body is processed — and <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#define POINT_H</code> is executed.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Second inclusion:</span> <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">POINT_H</code> <em style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);">is</em> now defined, so <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#ifndef</code> is false and the body is <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">skipped entirely</span>.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;">The body's contents land in your translation unit <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">exactly once</span>, no matter how many times or by which routes the header is included.</li></ol><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Verified — the same double-include, now guarded:</span></p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="" data-language="" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-id">SCENARIO</span> <span class="js-num">2</span><span class="js-op">:</span> <span class="js-id">point</span><span class="js-op">.</span><span class="js-id">h</span> <span class="js-id">WITH</span> #<span class="js-id">ifndef</span> <span class="js-id">include</span> <span class="js-id">guard</span><span class="js-op">---</span> <span class="js-id">preprocessed</span> <span class="js-id">output</span> <span class="js-op">(</span>#<span class="js-id">include</span> <span class="js-id">spliced</span> <span class="js-kw">in</span><span class="js-op">)</span> <span class="js-op">---</span><span class="js-id">typedef</span> <span class="js-id">struct</span> <span class="js-op">{</span> <span class="js-id">int</span> <span class="js-id">x</span><span class="js-op">,</span> <span class="js-id">y</span><span class="js-op">;</span> <span class="js-op">}</span> <span class="js-id">Point</span><span class="js-op">;</span>


<span class="js-id">int</span> <span class="js-id">main</span><span class="js-op">(</span><span class="js-kw">void</span><span class="js-op">)</span> <span class="js-op">{</span> <span class="js-id">Point</span> <span class="js-id">p</span><span class="js-op">;</span> <span class="js-kw">return</span> <span class="js-num">0</span><span class="js-op">;</span> <span class="js-op">}</span>
<span class="js-id">typedef</span><span class="js-op">-</span><span class="js-id">struct</span> <span class="js-id">definitions</span> <span class="js-kw">in</span> <span class="js-id">the</span> <span class="js-id">translation</span> <span class="js-id">unit</span><span class="js-op">:</span> <span class="js-num">1</span><span class="js-op">-&gt;</span> <span class="js-id">redefinition</span> <span class="js-kw">of</span> <span class="js-id">Point</span><span class="js-op">:</span> <span class="js-id">no</span> <span class="js-op">(</span><span class="js-id">guard</span> <span class="js-id">worked</span><span class="js-op">)</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Conventions worth adopting:</span></p><ul class="list-inside list-disc whitespace-normal [li_&amp;]:pl-6" data-streamdown="unordered-list" style="border: 0px solid rgb(47, 47, 55); margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); list-style: outside disc; padding-inline-start: 1.375rem; margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">The guard name should be unique</span> across the whole project — typically the filename uppercased with underscores (<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">POINT_H</code>, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">NETWORK_SOCKET_H</code>). A collision with another header's guard silently makes yours disappear, which is a nasty bug to track down.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Never use a leading underscore</span> for guard names — those are reserved for the implementation.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Comment the <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#endif</code></span> with the guard name (<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#endif /* POINT_H */</code>) so long headers stay readable.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Guard every header</span>, no exceptions, even ones you think will only be included once.</li></ul><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; letter-spacing: normal; padding: 0.1em 0.35em;">#pragma once</code></h3><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">Most compilers (GCC, Clang, MSVC) support this single-line alternative:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-id">pragma</span> <span class="js-id">oncetypedef</span> <span class="js-id">struct</span> <span class="js-op">{</span>
<span class="js-id">int</span> <span class="js-id">x</span><span class="js-op">,</span> <span class="js-id">y</span><span class="js-op">;</span>
<span class="js-op">}</span>
<span class="js-id">Point</span><span class="js-op">;</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Advantages:</span> one line, no name to invent, no collision risk, and typically faster (the compiler remembers the file rather than re-reading it to check guards).</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Disadvantages:</span> <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#pragma once</code> is not standard C</span> — it's a widely supported extension. And it identifies files by <em style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);">path</em>, so the same file reachable through two different paths (a symlink, a relative vs absolute include, a case-insensitive filesystem) can still be included twice.</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Practical recommendation:</span> include guards are portable and always correct; <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#pragma once</code> is convenient. Many projects use both — <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#pragma once</code> for speed plus a conventional guard for portability. Either is far better than nothing.</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><em style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);">(Suggested image: the second-inclusion path shown with the guard blocking it — a "skipped" panel where the body would have been)</em></p><hr class="my-6" data-streamdown="horizontal-rule" style="border-width: 1px 0px 0px; border-style: solid; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); height: 0px; margin-block: 1rem 0.75rem; --tw-space-y-reverse: 0; font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><h2 class="mt-6 mb-2 font-semibold text-2xl" data-streamdown="heading-2" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1.125rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.105469px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; letter-spacing: normal; padding: 0.1em 0.35em;">#define</code>: Macros Are Text Substitution</h2><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">There are two kinds of macro, and the difference between them is a pair of parentheses in the definition.</p><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);">Object-like macros — simple names for values</h3><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-id">define</span> <span class="js-id">PI</span> <span class="js-num">3.141592653589793</span>#<span class="js-id">define</span> <span class="js-id">MAX_ITEMS</span> <span class="js-num">100</span>#<span class="js-id">define</span> <span class="js-id">APP_NAME</span> <span class="js-str">"PreprocDemo"</span>#<span class="js-id">define</span> <span class="js-id">TAB</span> <span class="js-str">'\t'</span>#<span class="js-id">define</span> <span class="js-id">NEWLINE</span> <span class="js-str">"\n"</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">Wherever the name appears in later code, it's replaced. <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Verified translation unit</span> — starting from this source:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-id">include</span> <span class="js-str">"lib.h"</span>#<span class="js-id">include</span> <span class="js-str">"lib.h"</span>
<span class="js-id">int</span> <span class="js-id">main</span><span class="js-op">(</span><span class="js-kw">void</span><span class="js-op">)</span> <span class="js-op">{</span> <span class="js-id">int</span> <span class="js-id">buffer</span>[<span class="js-id">MAX_ITEMS</span>]<span class="js-op">;</span> <span class="js-id">printf</span><span class="js-op">(</span><span class="js-str">"%s version %d\n"</span><span class="js-op">,</span> <span class="js-id">APP_NAME</span><span class="js-op">,</span> <span class="js-id">VERSION</span><span class="js-op">);</span> <span class="js-kw">return</span> <span class="js-num">0</span><span class="js-op">;}</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">with <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">lib.h</code> containing <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">VERSION</code>, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">APP_NAME</code>, and <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">MAX_ITEMS</code> behind an include guard, the preprocessor produces:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-id">int</span> <span class="js-id">main</span><span class="js-op">(</span><span class="js-kw">void</span><span class="js-op">)</span> <span class="js-op">{</span>
<span class="js-id">int</span> <span class="js-id">buffer</span>[<span class="js-num">100</span>]<span class="js-op">;</span>
<span class="js-id">printf</span><span class="js-op">(</span><span class="js-str">"%s version %d\n"</span><span class="js-op">,</span> <span class="js-str">"PreprocDemo"</span><span class="js-op">,</span> <span class="js-num">3</span><span class="js-op">);</span>
<span class="js-kw">return</span> <span class="js-num">0</span><span class="js-op">;</span>
<span class="js-op">}</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">Checks on the output: <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#include</code> lines remaining: 0</span> · <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">macro names left unexpanded: 0</span> · <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">lib.h</code> spliced in exactly 1 time</span> (the guard working). Notice that the second <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#include</code> contributed nothing at all — and that <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">buffer[100]</code> is now a plain array declaration the compiler understands.</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">The rules that follow from "it's text":</span></p><ul class="list-inside list-disc whitespace-normal [li_&amp;]:pl-6" data-streamdown="unordered-list" style="border: 0px solid rgb(47, 47, 55); margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); list-style: outside disc; padding-inline-start: 1.375rem; margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">A macro is not a variable.</span> It has no address, no type, and no scope. It exists only as a name the preprocessor replaces.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">A macro name is not substituted inside string literals.</span> With <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#define VERSION 3</code>, the literal <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">"the VERSION here"</code> stays exactly as written — the preprocessor doesn't scan inside strings.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">A macro's effect starts at its definition and runs to the end of the file</span> — including into code below, past function boundaries, and inside any file that includes it afterward. There's no block scoping.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#define</code> inside a function body still has file scope</span> from that point on. It looks local and isn't.</li></ul><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);">Function-like macros — text with parameters</h3><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">Put <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">(</code> <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">immediately</span> after the name and it becomes parameterized:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-id">define</span> <span class="js-id">SQUARE</span><span class="js-op">(</span><span class="js-id">x</span><span class="js-op">)</span> <span class="js-op">((</span><span class="js-id">x</span><span class="js-op">)*(</span><span class="js-id">x</span><span class="js-op">))</span>#<span class="js-id">define</span> <span class="js-id">MAX</span><span class="js-op">(</span><span class="js-id">a</span><span class="js-op">,</span><span class="js-id">b</span><span class="js-op">)</span> <span class="js-op">((</span><span class="js-id">a</span><span class="js-op">)&gt;(</span><span class="js-id">b</span><span class="js-op">)?(</span><span class="js-id">a</span><span class="js-op">):(</span><span class="js-id">b</span><span class="js-op">))</span>#<span class="js-id">define</span> <span class="js-id">MIN</span><span class="js-op">(</span><span class="js-id">a</span><span class="js-op">,</span><span class="js-id">b</span><span class="js-op">)</span> <span class="js-op">((</span><span class="js-id">a</span><span class="js-op">)&lt;(</span><span class="js-id">b</span><span class="js-op">)?(</span><span class="js-id">a</span><span class="js-op">):(</span><span class="js-id">b</span><span class="js-op">))</span>#<span class="js-id">define</span> <span class="js-id">CLAMP</span><span class="js-op">(</span><span class="js-id">v</span><span class="js-op">,</span><span class="js-id">lo</span><span class="js-op">,</span><span class="js-id">hi</span><span class="js-op">)</span> <span class="js-op">((</span><span class="js-id">v</span><span class="js-op">)</span> <span class="js-op">&lt;</span> <span class="js-op">(</span><span class="js-id">lo</span><span class="js-op">)</span> <span class="js-op">?</span> <span class="js-op">(</span><span class="js-id">lo</span><span class="js-op">)</span> <span class="js-op">:</span> <span class="js-op">((</span><span class="js-id">v</span><span class="js-op">)</span> <span class="js-op">&gt;</span> <span class="js-op">(</span><span class="js-id">hi</span><span class="js-op">)</span> <span class="js-op">?</span> <span class="js-op">(</span><span class="js-id">hi</span><span class="js-op">)</span> <span class="js-op">:</span> <span class="js-op">(</span><span class="js-id">v</span><span class="js-op">)))</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">The critical detail: <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">the <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">(</code> must be adjacent to the name.</span> A space turns it into something completely different —</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-id">define</span> <span class="js-id">SQUARE</span> <span class="js-op">(</span><span class="js-id">x</span><span class="js-op">)</span> <span class="js-cm">/* ⚠ this is an OBJECT-like macro named SQUARE */</span> <span class="js-cm">/* whose body is the token sequence (x) */</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">Now <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">SQUARE(9)</code> expands to <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">(x)(9)</code> — a bewildering error. The same space-insensitive confusion does not exist anywhere else in the preprocessor, and it catches people once.</p><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);">The parenthesis rule — and why it's not optional</h3><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#define SQUARE(x) x*x</code> is the classic mistake. <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Verified expansion and evaluation:</span></p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="" data-language="" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-id">SQUARE</span><span class="js-op">(</span><span class="js-id">x</span><span class="js-op">)</span> <span class="js-op">=</span> <span class="js-id">x</span><span class="js-op">*</span><span class="js-id">x</span> <span class="js-id">SQUARE</span><span class="js-op">(</span><span class="js-num">1</span><span class="js-op">+</span><span class="js-num">2</span><span class="js-op">)</span> <span class="js-op">-&gt;</span> <span class="js-num">1</span><span class="js-op">+</span><span class="js-num">2</span><span class="js-op">*</span><span class="js-num">1</span><span class="js-op">+</span><span class="js-num">2</span> <span class="js-id">C</span> <span class="js-id">evaluates</span><span class="js-op">:</span> <span class="js-num">1</span> <span class="js-op">+</span> <span class="js-num">2</span><span class="js-op">*</span><span class="js-num">1</span> <span class="js-op">+</span> <span class="js-num">2</span> <span class="js-op">=</span> <span class="js-num">5</span> <span class="js-op">&lt;--</span> <span class="js-id">WRONG</span> <span class="js-op">(</span><span class="js-id">operator</span> <span class="js-id">precedence</span><span class="js-op">)</span>
<span class="js-id">SQUARE</span><span class="js-op">(</span><span class="js-id">x</span><span class="js-op">)</span> <span class="js-op">=</span> <span class="js-op">((</span><span class="js-id">x</span><span class="js-op">)*(</span><span class="js-id">x</span><span class="js-op">))</span> <span class="js-id">SQUARE</span><span class="js-op">(</span><span class="js-num">1</span><span class="js-op">+</span><span class="js-num">2</span><span class="js-op">)</span> <span class="js-op">-&gt;</span> <span class="js-op">((</span><span class="js-num">1</span><span class="js-op">+</span><span class="js-num">2</span><span class="js-op">)*(</span><span class="js-num">1</span><span class="js-op">+</span><span class="js-num">2</span><span class="js-op">))</span> <span class="js-id">C</span> <span class="js-id">evaluates</span><span class="js-op">:</span> <span class="js-op">(</span><span class="js-num">1</span><span class="js-op">+</span><span class="js-num">2</span><span class="js-op">)*(</span><span class="js-num">1</span><span class="js-op">+</span><span class="js-num">2</span><span class="js-op">)</span> <span class="js-op">=</span> <span class="js-num">9</span> <span class="js-op">&lt;--</span> <span class="js-id">CORRECT</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">The substitution is purely textual: <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">x</code> was replaced by <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">1+2</code> <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">without parentheses</span>, producing <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">x*x</code> → <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">1+2*1+2</code>. Normal C precedence then evaluates <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">2*1</code> first, giving <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">1 + 2 + 2 = 5</code> instead of the intended 9.</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">A second, larger failure of the same kind:</span></p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="" data-language="" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-id">SQUARE</span><span class="js-op">(</span><span class="js-id">a</span><span class="js-op">+</span><span class="js-id">b</span><span class="js-op">)</span> <span class="js-id">where</span> <span class="js-id">a</span><span class="js-op">=</span><span class="js-num">3</span><span class="js-op">,</span> <span class="js-id">b</span><span class="js-op">=</span><span class="js-num">4</span> <span class="js-op">(</span><span class="js-id">expected</span> <span class="js-num">49</span><span class="js-op">)</span> <span class="js-id">x</span><span class="js-op">*</span><span class="js-id">x</span> <span class="js-op">-&gt;</span> <span class="js-id">a</span><span class="js-op">+</span><span class="js-id">b</span><span class="js-op">*</span><span class="js-id">a</span><span class="js-op">+</span><span class="js-id">b</span> <span class="js-op">=</span> <span class="js-num">19</span> <span class="js-op">&lt;--</span> <span class="js-id">wrong</span> <span class="js-op">((</span><span class="js-id">x</span><span class="js-op">)*(</span><span class="js-id">x</span><span class="js-op">))</span> <span class="js-op">-&gt;</span> <span class="js-op">((</span><span class="js-id">a</span><span class="js-op">+</span><span class="js-id">b</span><span class="js-op">)*(</span><span class="js-id">a</span><span class="js-op">+</span><span class="js-id">b</span><span class="js-op">))</span> <span class="js-op">=</span> <span class="js-num">49</span> <span class="js-op">&lt;--</span> <span class="js-id">correct</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">That's a silently wrong answer with no warning, in code that reads correctly. <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">The rule has two halves, and both are required:</span></p><blockquote class="my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic" data-streamdown="blockquote" dir="ltr" style="border-width: 0px 0px 0px 4px; border-style: solid; border-color: oklab(0.768555 -0.00191316 -0.00942606 / 0.3); border-image: none; margin: 0px; padding: 0px 0px 0px 15px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 15px 0.75rem; --tw-space-y-reverse: 0; color: rgb(176, 180, 186); font-style: italic; font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Wrap every parameter in parentheses. Wrap the entire macro body in parentheses too.</span></p></blockquote><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">The body needs its own outer parentheses so the macro composes safely inside a larger expression:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-id">define</span> <span class="js-id">DOUBLE</span><span class="js-op">(</span><span class="js-id">x</span><span class="js-op">)</span> <span class="js-op">(</span><span class="js-id">x</span><span class="js-op">)+(</span><span class="js-id">x</span><span class="js-op">)</span> <span class="js-cm">/* ✗ body not enclosed */</span><span class="js-num">2</span> <span class="js-op">*</span> <span class="js-id">DOUBLE</span><span class="js-op">(</span><span class="js-num">3</span><span class="js-op">)</span> <span class="js-cm">/* → 2 * (3)+(3) = 9, not 12 */</span>
#<span class="js-id">define</span> <span class="js-id">DOUBLE</span><span class="js-op">(</span><span class="js-id">x</span><span class="js-op">)</span> <span class="js-op">((</span><span class="js-id">x</span><span class="js-op">)+(</span><span class="js-id">x</span><span class="js-op">))</span> <span class="js-cm">/* ✓ */</span><span class="js-num">2</span> <span class="js-op">*</span> <span class="js-id">DOUBLE</span><span class="js-op">(</span><span class="js-num">3</span><span class="js-op">)</span> <span class="js-cm">/* → 2 * ((3)+(3)) = 12 */</span></code></pre></div></div></div><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);">Multiple evaluation: arguments can run twice</h3><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">This is the subtler hazard, and it can't be fixed with parentheses:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-id">define</span> <span class="js-id">MAX</span><span class="js-op">(</span><span class="js-id">a</span><span class="js-op">,</span><span class="js-id">b</span><span class="js-op">)</span> <span class="js-op">((</span><span class="js-id">a</span><span class="js-op">)&gt;(</span><span class="js-id">b</span><span class="js-op">)?(</span><span class="js-id">a</span><span class="js-op">):(</span><span class="js-id">b</span><span class="js-op">))</span><span class="js-id">int</span> <span class="js-id">m</span> <span class="js-op">=</span> <span class="js-id">MAX</span><span class="js-op">(</span><span class="js-id">i</span><span class="js-op">++,</span> <span class="js-id">j</span><span class="js-op">++);</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">The argument <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">a</code> appears <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">twice</span> in the body (<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">(a)&gt;(b)</code> and the <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">? (a)</code>), and <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">b</code> appears twice too. So the arguments are <em style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);">evaluated</em> multiple times.</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Verified simulation of <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">MAX(i++, j++)</code> with <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">i = 1</code>, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">j = 2</code>:</span></p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="" data-language="" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-id">i</span> <span class="js-id">started</span> <span class="js-id">at</span> <span class="js-num">1</span><span class="js-op">,</span> <span class="js-id">j</span> <span class="js-id">started</span> <span class="js-id">at</span> <span class="js-num">2</span><span class="js-op">;</span> <span class="js-id">call</span> <span class="js-id">MAX</span><span class="js-op">(</span><span class="js-id">i</span><span class="js-op">++,</span> <span class="js-id">j</span><span class="js-op">++)</span> <span class="js-id">result</span> <span class="js-id">m</span> <span class="js-op">=</span> <span class="js-num">3</span> <span class="js-id">i</span> <span class="js-id">is</span> <span class="js-id">now</span> <span class="js-num">2</span> <span class="js-op">(</span><span class="js-id">incremented</span> 1x<span class="js-op">)</span> <span class="js-id">j</span> <span class="js-id">is</span> <span class="js-id">now</span> <span class="js-num">4</span> <span class="js-op">(</span><span class="js-id">incremented</span> 2x<span class="js-op">)</span> <span class="js-op">&lt;--</span> <span class="js-id">TWICE</span><span class="js-op">,</span> <span class="js-id">not</span> <span class="js-id">once</span><span class="js-op">!</span><span class="js-id">total</span> <span class="js-id">side</span> <span class="js-id">effects</span><span class="js-op">:</span> <span class="js-num">3</span> <span class="js-id">increments</span> <span class="js-kw">for</span> <span class="js-id">ONE</span> <span class="js-id">apparent</span> <span class="js-str">"argument each"</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">j</code> was incremented <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">twice</span> — once in the comparison, once in the chosen branch. The programmer wrote two <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">++</code> and got <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">three</span> increments. That's undefined behavior territory, and it's completely invisible at the call site.</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">The rule that prevents it:</span> never pass an argument with a side effect (increment, decrement, assignment, function call) to a macro that uses it more than once. Since you can't know that from the call site, the practical guidance is stronger:</p><blockquote class="my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic" data-streamdown="blockquote" dir="ltr" style="border-width: 0px 0px 0px 4px; border-style: solid; border-color: oklab(0.768555 -0.00191316 -0.00942606 / 0.3); border-image: none; margin: 0px; padding: 0px 0px 0px 15px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 15px 0.75rem; --tw-space-y-reverse: 0; color: rgb(176, 180, 186); font-style: italic; font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Never pass anything with a side effect to a macro.</span> Use a function instead.</p></blockquote><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);">Macros vs functions</h3><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">The honest comparison:</p><div class="my-4 flex flex-col gap-2 rounded-lg bg-sidebar p-2" data-streamdown="table-wrapper" style="border: 0.8px solid rgb(47, 47, 55); margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 0.5rem; margin-block: 1rem 0.75rem; overflow: hidden; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); gap: 0px; --tw-space-y-reverse: 0; display: flex; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px;"><div class="border-collapse" style="border: 1px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); border-collapse: collapse; border-radius: 5.5px; background-color: rgb(18, 18, 22); max-height: 300px;"><table class="w-full divide-y divide-border" data-streamdown="table" style="border-width: 0px; border-color: inherit; margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); text-indent: 0px; min-width: 100%; width: 951.2px;"><thead class="bg-muted/80" data-streamdown="table-header" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0; background-color: oklab(0.252138 0.000131465 -0.00581433 / 0.8);"><tr class="" data-streamdown="table-row" style="border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);"><th class="whitespace-nowrap px-4 py-2 text-left font-semibold text-sm" data-streamdown="table-header-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px; --tw-font-weight: 600; white-space: nowrap;"></th><th class="whitespace-nowrap px-4 py-2 text-left font-semibold text-sm" data-streamdown="table-header-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px; --tw-font-weight: 600; white-space: nowrap;">Macro</th><th class="whitespace-nowrap px-4 py-2 text-left font-semibold text-sm" data-streamdown="table-header-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px; --tw-font-weight: 600; white-space: nowrap;">Function</th></tr></thead><tbody class="divide-y divide-border" data-streamdown="table-body" style="border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);"><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Mechanism</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Text substitution at preprocessing time</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Real call at runtime</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Type checking</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">None</span></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Full</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Argument evaluation</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Can happen multiple times</span></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Exactly once</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Debugging</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Not debuggable</span> — invisible at runtime</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Normal breakpoints/stepping</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Code size</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Expands at every use site</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">One copy</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Overhead</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">None (no call)</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Call overhead (often inlined anyway)</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Can take a type as an argument</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Yes</span> (<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#define ARRAY_LEN(a) (sizeof(a)/sizeof((a)[0]))</code>)</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">No</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Can work on any type</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Yes</span> (generic by text)</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">No — must be per-type</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Scoping</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Ignored</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Proper scope</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#</code> and <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">##</code> operators</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Yes</span></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">No</td></tr><tr class="" data-streamdown="table-row" style="border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Best for</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Constants, conditional compilation, generic type-agnostic operations, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">sizeof</code> idioms</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Everything else</td></tr></tbody></table></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Use a function unless you specifically need what only a macro provides</span> — a type parameter, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">sizeof</code> on the caller's actual array, no call overhead in a hot path, or participation in conditional compilation. Modern compilers inline small functions aggressively, so "performance" is rarely a real justification anymore.</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Except</span> for the array-length idiom, where a macro is genuinely the only option:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-id">define</span> <span class="js-id">ARRAY_LEN</span><span class="js-op">(</span><span class="js-id">a</span><span class="js-op">)</span> <span class="js-op">(</span><span class="js-id">sizeof</span><span class="js-op">(</span><span class="js-id">a</span><span class="js-op">)</span> <span class="js-op">/</span> <span class="js-id">sizeof</span><span class="js-op">((</span><span class="js-id">a</span><span class="js-op">)</span>[<span class="js-num">0</span>]<span class="js-op">))</span>
<span class="js-id">int</span> <span class="js-id">data</span>[<span class="js-num">50</span>]<span class="js-op">;</span><span class="js-id">printf</span><span class="js-op">(</span><span class="js-str">"%zu\n"</span><span class="js-op">,</span> <span class="js-id">ARRAY_LEN</span><span class="js-op">(</span><span class="js-id">data</span><span class="js-op">));</span> <span class="js-cm">/* 50 */</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">This only works on a real array in the same scope — pass it a pointer and you get the pointer's size divided by the element size, which is why it's so easy to get wrong. (It's the "arrays decay to pointers" rule, showing up inside a macro.)</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><em style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);">(Suggested image: the SQUARE comparison — the bad expansion <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">1+2*1+2</code> and the good <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">((1+2)*(1+2))</code> side by side with their results 5 and 9 marked correct/incorrect)</em></p><hr class="my-6" data-streamdown="horizontal-rule" style="border-width: 1px 0px 0px; border-style: solid; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); height: 0px; margin-block: 1rem 0.75rem; --tw-space-y-reverse: 0; font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><h2 class="mt-6 mb-2 font-semibold text-2xl" data-streamdown="heading-2" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1.125rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.105469px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);">Multi-Statement Macros and the <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; letter-spacing: normal; padding: 0.1em 0.35em;">do { } while (0)</code> Idiom</h2><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">A macro that expands to several statements has a specific problem. Naively:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-id">define</span> <span class="js-id">SWAP</span><span class="js-op">(</span><span class="js-id">a</span><span class="js-op">,</span> <span class="js-id">b</span><span class="js-op">)</span> <span class="js-op">{</span>
<span class="js-id">int</span> <span class="js-id">t</span> <span class="js-op">=</span> <span class="js-id">a</span><span class="js-op">;</span>
<span class="js-id">a</span> <span class="js-op">=</span> <span class="js-id">b</span><span class="js-op">;</span>
<span class="js-id">b</span> <span class="js-op">=</span> <span class="js-id">t</span><span class="js-op">;</span>
<span class="js-op">}</span>
<span class="js-cm">/* ⚠ */</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">Used inside an <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">if</code> without braces:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-kw">if</span> <span class="js-op">(</span><span class="js-id">x</span> <span class="js-op">&gt;</span> <span class="js-id">y</span><span class="js-op">)</span> <span class="js-id">SWAP</span><span class="js-op">(</span><span class="js-id">x</span><span class="js-op">,</span> <span class="js-id">y</span><span class="js-op">);</span>
<span class="js-kw">else</span> <span class="js-id">puts</span><span class="js-op">(</span><span class="js-str">"already ordered"</span><span class="js-op">);</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">After expansion:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-kw">if</span> <span class="js-op">(</span><span class="js-id">x</span> <span class="js-op">&gt;</span> <span class="js-id">y</span><span class="js-op">)</span> <span class="js-op">{</span>
<span class="js-id">int</span> <span class="js-id">t</span> <span class="js-op">=</span> <span class="js-id">x</span><span class="js-op">;</span>
<span class="js-id">x</span> <span class="js-op">=</span> <span class="js-id">y</span><span class="js-op">;</span>
<span class="js-id">y</span> <span class="js-op">=</span> <span class="js-id">t</span><span class="js-op">;</span>
<span class="js-op">}</span>
<span class="js-op">;</span> <span class="js-cm">/* ← this semicolon! */</span><span class="js-kw">else</span> <span class="js-id">puts</span><span class="js-op">(</span><span class="js-str">"already ordered"</span><span class="js-op">);</span> <span class="js-cm">/* ← orphaned else: compile error */</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">The user's <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">;</code> after the macro becomes a <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">null statement</span>, which terminates the <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">if</code> — leaving the <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">else</code> with no <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">if</code>. It compiles fine in the bare form and breaks the moment it's used in an <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">if</code>/<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">else</code>. That's the worst kind of bug: it depends on where the macro is used.</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">The standard fix wraps the body in a loop that runs exactly once:</span></p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-id">define</span> <span class="js-id">SWAP</span><span class="js-op">(</span><span class="js-id">a</span><span class="js-op">,</span> <span class="js-id">b</span><span class="js-op">)</span> <span class="js-kw">do</span> <span class="js-op">{</span>
<span class="js-id">int</span> <span class="js-id">t</span> <span class="js-op">=</span> <span class="js-id">a</span><span class="js-op">;</span>
<span class="js-id">a</span> <span class="js-op">=</span> <span class="js-id">b</span><span class="js-op">;</span>
<span class="js-id">b</span> <span class="js-op">=</span> <span class="js-id">t</span><span class="js-op">;</span>
<span class="js-op">}</span>
<span class="js-kw">while</span> <span class="js-op">(</span><span class="js-num">0</span><span class="js-op">)</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">Now the expansion is:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-kw">if</span> <span class="js-op">(</span><span class="js-id">x</span> <span class="js-op">&gt;</span> <span class="js-id">y</span><span class="js-op">)</span> <span class="js-kw">do</span> <span class="js-op">{</span>
<span class="js-id">int</span> <span class="js-id">t</span> <span class="js-op">=</span> <span class="js-id">x</span><span class="js-op">;</span>
<span class="js-id">x</span> <span class="js-op">=</span> <span class="js-id">y</span><span class="js-op">;</span>
<span class="js-id">y</span> <span class="js-op">=</span> <span class="js-id">t</span><span class="js-op">;</span>
<span class="js-op">}</span>
<span class="js-kw">while</span> <span class="js-op">(</span><span class="js-num">0</span><span class="js-op">);</span> <span class="js-cm">/* one complete statement */</span><span class="js-kw">else</span> <span class="js-id">puts</span><span class="js-op">(</span><span class="js-str">"already ordered"</span><span class="js-op">);</span> <span class="js-cm">/* else still attached ✓ */</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">The <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">do { } while (0)</code> consumes the caller's semicolon correctly, behaves as a <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">single statement</span> in every context, and requires a trailing <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">;</code> at the call site just like any other statement — so it <em style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);">looks</em> like a function call:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-id">SWAP</span><span class="js-op">(</span><span class="js-id">a</span><span class="js-op">,</span> <span class="js-id">b</span><span class="js-op">);</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Two cautions:</span> the temporary <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">t</code> could shadow an outer <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">t</code> — the block scope inside <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">do { }</code> protects the <em style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);">caller's</em> variable, but if the macro's arguments are named <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">t</code> themselves you'd have a conflict, so distinctive internal names are worth using. And <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">do { } while (0)</code> contains <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">break</code>/<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">continue</code> semantics — the block is a real loop, so a <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">break</code> inside would exit it.</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">A useful companion idiom</span> for "does nothing when disabled," so a macro can be switched off without leaving syntax errors:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-id">ifdef</span> <span class="js-id">DEBUG</span> #<span class="js-id">define</span> <span class="js-id">DBG</span><span class="js-op">(...)</span> <span class="js-kw">do</span> <span class="js-op">{</span>
<span class="js-id">fprintf</span><span class="js-op">(</span><span class="js-id">stderr</span><span class="js-op">,</span> <span class="js-id">__VA_ARGS__</span><span class="js-op">);</span>
<span class="js-op">}</span>
<span class="js-kw">while</span> <span class="js-op">(</span><span class="js-num">0</span><span class="js-op">)</span>#<span class="js-kw">else</span> #<span class="js-id">define</span> <span class="js-id">DBG</span><span class="js-op">(...)</span> <span class="js-op">((</span><span class="js-kw">void</span><span class="js-op">)</span><span class="js-num">0</span><span class="js-op">)</span> <span class="js-cm">/* a valid, do-nothing statement */</span>#<span class="js-id">endif</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><em style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);">(Suggested image: the SWAP macro used in an if/else — first the broken expansion with the orphaned else, then the do-while(0) version working)</em></p><hr class="my-6" data-streamdown="horizontal-rule" style="border-width: 1px 0px 0px; border-style: solid; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); height: 0px; margin-block: 1rem 0.75rem; --tw-space-y-reverse: 0; font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><h2 class="mt-6 mb-2 font-semibold text-2xl" data-streamdown="heading-2" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1.125rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.105469px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);">The <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; letter-spacing: normal; padding: 0.1em 0.35em;">#</code> and <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; letter-spacing: normal; padding: 0.1em 0.35em;">##</code> Operators</h2><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">These two operators exist only inside macro bodies.</p><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; letter-spacing: normal; padding: 0.1em 0.35em;">#</code> — stringize</h3><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">Turns the macro argument into a string literal:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-id">define</span> <span class="js-id">STR</span><span class="js-op">(</span><span class="js-id">x</span><span class="js-op">)</span> #<span class="js-id">x</span>#<span class="js-id">define</span> <span class="js-id">XSTR</span><span class="js-op">(</span><span class="js-id">x</span><span class="js-op">)</span> <span class="js-id">STR</span><span class="js-op">(</span><span class="js-id">x</span><span class="js-op">)</span> <span class="js-cm">/* two-step, so a macro arg expands first */</span>
<span class="js-id">STR</span><span class="js-op">(</span><span class="js-id">hello</span><span class="js-op">)</span> <span class="js-cm">/* → "hello" */</span><span class="js-id">STR</span><span class="js-op">(</span><span class="js-num">1</span> <span class="js-op">+</span> <span class="js-num">2</span><span class="js-op">)</span> <span class="js-cm">/* → "1 + 2" (not 3 — it's text!) */</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Why the two-step <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">XSTR</code> is needed:</span> <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">STR(VERSION)</code> gives <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">"VERSION"</code> — the literal name, because the argument is stringized before it's expanded. <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">XSTR(VERSION)</code> first expands <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">VERSION</code> to <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">3</code>, then stringizes, giving <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">"3"</code>. That double-layer trick appears constantly in real code.</p><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; letter-spacing: normal; padding: 0.1em 0.35em;">##</code> — token paste</h3><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">Glues two tokens into one:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-id">define</span> <span class="js-id">CONCAT</span><span class="js-op">(</span><span class="js-id">a</span><span class="js-op">,</span> <span class="js-id">b</span><span class="js-op">)</span> <span class="js-id">a</span>##<span class="js-id">b</span>
<span class="js-id">CONCAT</span><span class="js-op">(</span><span class="js-kw">var</span><span class="js-op">,</span> <span class="js-num">1</span><span class="js-op">)</span> <span class="js-cm">/* → var1 */</span><span class="js-id">CONCAT</span><span class="js-op">(</span><span class="js-id">int_</span><span class="js-op">,</span> <span class="js-num">32</span><span class="js-op">)</span> <span class="js-cm">/* → int_32 */</span></code></pre></div></div></div><h2 class="mt-6 mb-2 font-semibold text-2xl" data-streamdown="heading-2" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1.125rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.105469px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);">is how you <em style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);">generate</em> identifiers — used heavily in the X-macro pattern below and in generated dispatch tables.</h2><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">A combined example — a compile-time assertion:</span></p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-id">define</span> <span class="js-id">STATIC_ASSERT</span><span class="js-op">(</span><span class="js-id">cond</span><span class="js-op">,</span> <span class="js-id">msg</span><span class="js-op">)</span> \ <span class="js-id">typedef</span> <span class="js-id">char</span> <span class="js-id">static_assert_</span>##<span class="js-id">msg</span>[<span class="js-op">(</span><span class="js-id">cond</span><span class="js-op">)</span> <span class="js-op">?</span> <span class="js-num">1</span> <span class="js-op">:</span> <span class="js-op">-</span><span class="js-num">1</span>]</code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">If <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">cond</code> is false, this declares an array of size <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">-1</code> — a guaranteed compile error, with <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">msg</code> appearing in the type name so you can see which assertion failed. That's a genuine C89-compatible technique.</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><em style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);">(Suggested image: the # operator taking the argument text and wrapping it in quotes, and ## fusing two tokens into one)</em></p><hr class="my-6" data-streamdown="horizontal-rule" style="border-width: 1px 0px 0px; border-style: solid; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); height: 0px; margin-block: 1rem 0.75rem; --tw-space-y-reverse: 0; font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><h2 class="mt-6 mb-2 font-semibold text-2xl" data-streamdown="heading-2" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1.125rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.105469px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);">Variadic Macros: <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; letter-spacing: normal; padding: 0.1em 0.35em;">__VA_ARGS__</code></h2><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">C99 added macros that accept a variable number of arguments:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-id">define</span> <span class="js-id">LOG</span><span class="js-op">(</span><span class="js-id">fmt</span><span class="js-op">,</span> <span class="js-op">...)</span> <span class="js-id">fprintf</span><span class="js-op">(</span><span class="js-id">stderr</span><span class="js-op">,</span> <span class="js-str">"[log] "</span> <span class="js-id">fmt</span> <span class="js-str">"\n"</span><span class="js-op">,</span> <span class="js-id">__VA_ARGS__</span><span class="js-op">)</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">__VA_ARGS__</code> is replaced by everything after the named parameters, commas included. It's mainly useful for <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">wrapping functions that are themselves variadic</span> — <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">printf</code>, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">fprintf</code>, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">snprintf</code> — which is exactly what logging needs:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-id">LOG</span><span class="js-op">(</span><span class="js-str">"count = %d"</span><span class="js-op">,</span> <span class="js-id">count</span><span class="js-op">);</span> <span class="js-cm">/* → fprintf(stderr, "[log] " "count = %d" "\n", count) */</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">Note the <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">string-literal concatenation</span>: <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">"[log] " fmt "\n"</code> works because adjacent string literals are joined by the compiler (<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">fmt</code> arrives as a literal in the common case).</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">The pre-C23 wrinkle:</span> if <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">__VA_ARGS__</code> is empty, you get a dangling comma:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-id">LOG</span><span class="js-op">(</span><span class="js-str">"done"</span><span class="js-op">);</span> <span class="js-cm">/* → fprintf(stderr, "[log] " "done" "\n", ) ← error! */</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">The GNU workaround</span> (widely supported, not standard before C23) uses <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">##</code> to swallow the comma:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-id">define</span> <span class="js-id">LOG</span><span class="js-op">(</span><span class="js-id">fmt</span><span class="js-op">,</span> <span class="js-op">...)</span> <span class="js-id">fprintf</span><span class="js-op">(</span><span class="js-id">stderr</span><span class="js-op">,</span> <span class="js-str">"[log] "</span> <span class="js-id">fmt</span> <span class="js-str">"\n"</span><span class="js-op">,</span> ##<span class="js-id">__VA_ARGS__</span><span class="js-op">)</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">C23 standardizes <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">__VA_OPT__(...)</code></span> for this:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-id">define</span> <span class="js-id">LOG</span><span class="js-op">(</span><span class="js-id">fmt</span><span class="js-op">,</span> <span class="js-op">...)</span> <span class="js-id">fprintf</span><span class="js-op">(</span><span class="js-id">stderr</span><span class="js-op">,</span> <span class="js-str">"[log] "</span> <span class="js-id">fmt</span> <span class="js-str">"%s\n"</span><span class="js-op">,</span> <span class="js-id">__VA_OPT__</span><span class="js-op">(,)</span> <span class="js-id">__VA_ARGS__</span><span class="js-op">)</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">For portable code before C23, the safe approach is to require at least one variable argument, or write two macros (a single-argument version and a variadic version).</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><em style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);">(Suggested image: the variadic macro expansion showing <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">VA_ARGS</span> replaced by the trailing arguments, and the empty-argument comma problem marked)</em></p><hr class="my-6" data-streamdown="horizontal-rule" style="border-width: 1px 0px 0px; border-style: solid; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); height: 0px; margin-block: 1rem 0.75rem; --tw-space-y-reverse: 0; font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><h2 class="mt-6 mb-2 font-semibold text-2xl" data-streamdown="heading-2" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1.125rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.105469px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);">Predefined Macros</h2><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">The preprocessor comes with a set of macros already defined. These cost nothing and are genuinely useful.</p><div class="my-4 flex flex-col gap-2 rounded-lg bg-sidebar p-2" data-streamdown="table-wrapper" style="border: 0.8px solid rgb(47, 47, 55); margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 0.5rem; margin-block: 1rem 0.75rem; overflow: hidden; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); gap: 0px; --tw-space-y-reverse: 0; display: flex; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px;"><div class="border-collapse" style="border: 1px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); border-collapse: collapse; border-radius: 5.5px; background-color: rgb(18, 18, 22); max-height: 300px;"><table class="w-full divide-y divide-border" data-streamdown="table" style="border-width: 0px; border-color: inherit; margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); text-indent: 0px; min-width: 100%; width: 951.2px;"><thead class="bg-muted/80" data-streamdown="table-header" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0; background-color: oklab(0.252138 0.000131465 -0.00581433 / 0.8);"><tr class="" data-streamdown="table-row" style="border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);"><th class="whitespace-nowrap px-4 py-2 text-left font-semibold text-sm" data-streamdown="table-header-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px; --tw-font-weight: 600; white-space: nowrap;">Macro</th><th class="whitespace-nowrap px-4 py-2 text-left font-semibold text-sm" data-streamdown="table-header-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px; --tw-font-weight: 600; white-space: nowrap;">Value</th><th class="whitespace-nowrap px-4 py-2 text-left font-semibold text-sm" data-streamdown="table-header-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px; --tw-font-weight: 600; white-space: nowrap;">Type</th></tr></thead><tbody class="divide-y divide-border" data-streamdown="table-body" style="border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);"><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">__FILE__</code></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">The current source file name</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">String literal</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">__LINE__</code></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">The current line number</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Integer</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">__DATE__</code></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Compilation date, e.g. <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">"Sep 28 2026"</code></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">String literal</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">__TIME__</code></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Compilation time, e.g. <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">"14:35:02"</code></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">String literal</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">__func__</code></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Current function name</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><em style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);">(not a macro — a predefined identifier, C99)</em></td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">__STDC__</code></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">1</code> in a conforming implementation</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Integer</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">__STDC_VERSION__</code></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">e.g. <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">199901L</code> (C99), <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">201112L</code> (C11), <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">201710L</code> (C17)</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Integer</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">__STDC_HOSTED__</code></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">1</code> if a hosted implementation</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Integer</td></tr><tr class="" data-streamdown="table-row" style="border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">__cplusplus</code></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Defined only when compiled as C++</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">—</td></tr></tbody></table></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">The diagnostic trio is the practical payoff:</span></p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-id">define</span> <span class="js-id">ERROR</span><span class="js-op">(</span><span class="js-id">fmt</span><span class="js-op">,</span> <span class="js-op">...)</span> \ <span class="js-id">fprintf</span><span class="js-op">(</span><span class="js-id">stderr</span><span class="js-op">,</span> <span class="js-str">"%s:%d: "</span> <span class="js-id">fmt</span> <span class="js-str">"\n"</span><span class="js-op">,</span> <span class="js-id">__FILE__</span><span class="js-op">,</span> <span class="js-id">__LINE__</span><span class="js-op">,</span> <span class="js-id">__VA_ARGS__</span><span class="js-op">)</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">That produces compiler-style messages with exact locations, for free:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="" data-language="" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-id">network</span><span class="js-op">.</span><span class="js-id">c</span><span class="js-op">:</span><span class="js-num">142</span><span class="js-op">:</span> <span class="js-id">connection</span> <span class="js-id">timed</span> <span class="js-id">out</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Platform and compiler detection</span> uses the same machinery — these macros are defined by the implementation:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-kw">if</span> <span class="js-id">defined</span><span class="js-op">(</span><span class="js-id">_WIN32</span><span class="js-op">)</span> #<span class="js-id">define</span> <span class="js-id">PATH_SEP</span> <span class="js-str">'\\'</span>#<span class="js-id">elif</span> <span class="js-id">defined</span><span class="js-op">(</span><span class="js-id">__APPLE__</span><span class="js-op">)</span> #<span class="js-id">define</span> <span class="js-id">PATH_SEP</span> <span class="js-str">'/'</span>#<span class="js-id">elif</span> <span class="js-id">defined</span><span class="js-op">(</span><span class="js-id">__linux__</span><span class="js-op">)</span> #<span class="js-id">define</span> <span class="js-id">PATH_SEP</span> <span class="js-str">'/'</span>#<span class="js-kw">else</span> #<span class="js-id">error</span> <span class="js-str">"Unsupported platform"</span>#<span class="js-id">endif</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">Common ones: <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">_WIN32</code> / <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">_WIN64</code> (MSVC and MinGW), <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">__linux__</code>, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">__APPLE__</code>, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">__unix__</code>, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">__GNUC__</code> / <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">__GNUC_MINOR__</code>, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">__clang__</code>, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">_MSC_VER</code>. <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Test with <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">defined()</code>, never by value</span> — the values differ between compilers and none of them means what you'd guess.</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">And <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">__DATE__</code>/<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">__TIME__</code> are a build-timestamp trick worth knowing</span> — they let a program report when it was built:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-id">printf</span><span class="js-op">(</span><span class="js-str">"Built %s at %s\n"</span><span class="js-op">,</span> <span class="js-id">__DATE__</span><span class="js-op">,</span> <span class="js-id">__TIME__</span><span class="js-op">);</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">The catch: these are fixed at <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">compile time</span>, so they only change when the file is recompiled — not when the program runs. And they make builds non-reproducible, since identical source produces different binaries on different days.</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><em style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);">(Suggested image: a source line and the compiler-style diagnostic it produces, with <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">FILE</span> and <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">LINE</span> highlighted as the sources of the path and number)</em></p><hr class="my-6" data-streamdown="horizontal-rule" style="border-width: 1px 0px 0px; border-style: solid; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); height: 0px; margin-block: 1rem 0.75rem; --tw-space-y-reverse: 0; font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><h2 class="mt-6 mb-2 font-semibold text-2xl" data-streamdown="heading-2" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1.125rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.105469px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);">Conditional Compilation</h2><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">The directives that make code appear or disappear before compilation:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-kw">if</span> <span class="js-id">constant</span><span class="js-op">-</span><span class="js-id">expression</span>#<span class="js-id">ifdef</span> <span class="js-id">NAME</span>#<span class="js-id">ifndef</span> <span class="js-id">NAME</span>#<span class="js-id">elif</span> <span class="js-id">constant</span><span class="js-op">-</span><span class="js-id">expression</span>#<span class="js-kw">else</span>#<span class="js-id">endif</span></code></pre></div></div></div><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; letter-spacing: normal; padding: 0.1em 0.35em;">#ifdef</code> / <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; letter-spacing: normal; padding: 0.1em 0.35em;">#ifndef</code> — is this name defined?</h3><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-id">ifdef</span> <span class="js-id">_WIN32</span> #<span class="js-id">include</span> <span class="js-op">&lt;</span><span class="js-id">windows</span><span class="js-op">.</span><span class="js-id">h</span><span class="js-op">&gt;</span>#<span class="js-kw">else</span> #<span class="js-id">include</span> <span class="js-op">&lt;</span><span class="js-id">unistd</span><span class="js-op">.</span><span class="js-id">h</span><span class="js-op">&gt;</span>#<span class="js-id">endif</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#ifndef</code> is the same test negated — which is why it's the include-guard directive.</p><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; letter-spacing: normal; padding: 0.1em 0.35em;">#if</code> — evaluate a constant expression</h3><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#if</code> is more powerful: it evaluates a <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">constant integer expression</span> using <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">defined()</code> and the usual arithmetic and logical operators.</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-kw">if</span> <span class="js-id">defined</span><span class="js-op">(</span><span class="js-id">__STDC_VERSION__</span><span class="js-op">)</span> <span class="js-op">&amp;&amp;</span> <span class="js-id">__STDC_VERSION__</span> <span class="js-op">&gt;=</span> 201112L <span class="js-cm">/* C11 or later available */</span> #<span class="js-id">define</span> <span class="js-id">HAVE_ATOMICS</span> <span class="js-num">1</span>#<span class="js-id">endif</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Rules that surprise people:</span></p><ul class="list-inside list-disc whitespace-normal [li_&amp;]:pl-6" data-streamdown="unordered-list" style="border: 0px solid rgb(47, 47, 55); margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); list-style: outside disc; padding-inline-start: 1.375rem; margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Only integer arithmetic.</span> No floating point, no casts, no <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">sizeof</code>, no function calls, and no runtime values. It's evaluated by the preprocessor, which knows nothing about your program.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Undefined identifiers evaluate to <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">0</code>.</span> So <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#if VERSION &gt; 2</code> is false when <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">VERSION</code> isn't defined — silently, without error. This is a real hazard: a typo'd name gives a false condition rather than a diagnostic. Most compilers warn about this (<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">-Wundef</code> in GCC/Clang), and it's worth enabling.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">defined(NAME)</code> or <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">defined NAME</code></span> — both forms legal; <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">defined(NAME)</code> is clearer.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Prefer <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#if defined(X)</code> over <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#ifdef X</code></span> when you need to combine conditions — you can't write <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#ifdef X &amp;&amp; Y</code>. The short-circuit <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">&amp;&amp;</code>/<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">||</code> in <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#if</code> is what makes multi-condition tests possible.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Structural directives must nest properly.</span> Every <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#if</code>/<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#ifdef</code> needs its own <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#endif</code>; <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#elif</code> and <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#else</code> must belong to the current level.</li></ul><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; letter-spacing: normal; padding: 0.1em 0.35em;">#if 0</code> — commenting out code</h3><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">The one thing <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#if 0</code> does better than <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">/* */</code>: it <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">nests</span>.</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-kw">if</span> <span class="js-num">0</span> <span class="js-cm">/* the block comments below would break this if it were commented out with /* ... *\/ instead */</span> <span class="js-id">int</span> <span class="js-id">x</span> <span class="js-op">=</span> <span class="js-num">1</span><span class="js-op">;</span> <span class="js-cm">/* an inner comment */</span> <span class="js-id">int</span> <span class="js-id">y</span> <span class="js-op">=</span> <span class="js-num">2</span><span class="js-op">;</span>#<span class="js-id">endif</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">C comments don't nest, so commenting out a region that already contains comments fails. <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#if 0 ... #endif</code> doesn't care. It's the reliable way to temporarily disable a block — and the preprocessor removes it entirely, so it costs nothing in the translation unit.</p><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; letter-spacing: normal; padding: 0.1em 0.35em;">#error</code> — fail the build deliberately</h3><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-kw">if</span> <span class="js-op">!</span><span class="js-id">defined</span><span class="js-op">(</span><span class="js-id">__STDC_VERSION__</span><span class="js-op">)</span> <span class="js-op">||</span> <span class="js-id">__STDC_VERSION__</span> <span class="js-op">&lt;</span> 199901L#<span class="js-id">error</span> <span class="js-str">"This program requires C99 or later"</span>#<span class="js-id">endif</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#error</code> <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">stops compilation</span> and prints your message. That's exactly what you want for a platform the code can't support, or a required configuration that's missing — it turns hours of confusing downstream errors into one clear statement at the top of the build. <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#error</code> is standard C.</span> (<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#warning</code>, which continues compilation, became standard in C23; before that it was a common extension.)</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><em style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);">(Suggested image: the conditional-compilation tree — one source file branching into platform-specific regions, with non-taken branches greyed out before the compiler sees them)</em></p><hr class="my-6" data-streamdown="horizontal-rule" style="border-width: 1px 0px 0px; border-style: solid; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); height: 0px; margin-block: 1rem 0.75rem; --tw-space-y-reverse: 0; font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><h2 class="mt-6 mb-2 font-semibold text-2xl" data-streamdown="heading-2" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1.125rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.105469px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);">Practical Patterns Worth Copying</h2><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);">1. Configurable debug logging</h3><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-cm">/* debug.h */</span>#<span class="js-id">ifndef</span> <span class="js-id">DEBUG_H</span>#<span class="js-id">define</span> <span class="js-id">DEBUG_H</span>
#<span class="js-id">ifdef</span> <span class="js-id">DEBUG</span> #<span class="js-id">define</span> <span class="js-id">DBG</span><span class="js-op">(...)</span> <span class="js-kw">do</span> <span class="js-op">{</span> \ <span class="js-id">fprintf</span><span class="js-op">(</span><span class="js-id">stderr</span><span class="js-op">,</span> <span class="js-str">"[%s:%d] "</span><span class="js-op">,</span> <span class="js-id">__FILE__</span><span class="js-op">,</span> <span class="js-id">__LINE__</span><span class="js-op">);</span> \ <span class="js-id">fprintf</span><span class="js-op">(</span><span class="js-id">stderr</span><span class="js-op">,</span> <span class="js-id">__VA_ARGS__</span><span class="js-op">);</span> \ <span class="js-id">fputc</span><span class="js-op">(</span><span class="js-str">'\n'</span><span class="js-op">,</span> <span class="js-id">stderr</span><span class="js-op">);</span> \ <span class="js-op">}</span> <span class="js-kw">while</span> <span class="js-op">(</span><span class="js-num">0</span><span class="js-op">)</span>#<span class="js-kw">else</span> #<span class="js-id">define</span> <span class="js-id">DBG</span><span class="js-op">(...)</span> <span class="js-op">((</span><span class="js-kw">void</span><span class="js-op">)</span><span class="js-num">0</span><span class="js-op">)</span>#<span class="js-id">endif</span>
#<span class="js-id">endif</span> <span class="js-cm">/* DEBUG_H */</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">Compile with <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">-DDEBUG</code> to enable, without it to compile every <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">DBG(...)</code> call into nothing. <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Zero runtime cost when disabled, and no <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#ifdef</code> clutter at the call sites</span> — the calls stay in the source and simply vanish. Note the backslashes continuing the multi-line macro, and that each one must be the <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">last character on its line</span> (no trailing spaces — a trailing space after <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">\</code> breaks the continuation, which is a genuinely maddening bug).</p><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);">2. Assertions that vanish in release builds</h3><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-id">include</span> <span class="js-op">&lt;</span><span class="js-id">assert</span><span class="js-op">.</span><span class="js-id">h</span><span class="js-op">&gt;</span><span class="js-id">assert</span><span class="js-op">(</span><span class="js-id">ptr</span> <span class="js-op">!=</span> <span class="js-id">NULL</span><span class="js-op">);</span> <span class="js-cm">/* calls abort() if false — disabled by NDEBUG */</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">assert</code> is itself a macro, and <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">&lt;assert.h&gt;</code> defines it to test <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">NDEBUG</code>:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-cm">/* what the header effectively contains */</span>#<span class="js-id">ifdef</span> <span class="js-id">NDEBUG</span> #<span class="js-id">define</span> <span class="js-id">assert</span><span class="js-op">(</span><span class="js-id">expr</span><span class="js-op">)</span> <span class="js-op">((</span><span class="js-kw">void</span><span class="js-op">)</span><span class="js-num">0</span><span class="js-op">)</span>#<span class="js-kw">else</span> #<span class="js-id">define</span> <span class="js-id">assert</span><span class="js-op">(</span><span class="js-id">expr</span><span class="js-op">)</span> <span class="js-op">((</span><span class="js-id">expr</span><span class="js-op">)</span> <span class="js-op">?</span> <span class="js-op">(</span><span class="js-kw">void</span><span class="js-op">)</span><span class="js-num">0</span> <span class="js-op">:</span> <span class="js-id">__assert_fail</span><span class="js-op">(...))</span>#<span class="js-id">endif</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">Compile with <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">-DNDEBUG</code> (or <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#define NDEBUG</code> before including <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">&lt;assert.h&gt;</code>) and every assertion compiles away. <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">That's why <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">assert</code> must never contain a side effect</span> — <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">assert(scanf("%d", &amp;x) == 1)</code> silently stops reading input in release builds. Use it to check things that must be true, never to do work.</p><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);">3. Feature flags</h3><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-id">define</span> <span class="js-id">FEATURE_LOGGING</span> <span class="js-num">1</span>
#<span class="js-kw">if</span> <span class="js-id">FEATURE_LOGGING</span> <span class="js-cm">/* logging code compiled in */</span>#<span class="js-id">endif</span></code></pre></div></div></div><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);">4. <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; letter-spacing: normal; padding: 0.1em 0.35em;">#undef</code> and temporary macros</h3><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#undef NAME</code></span> removes a macro definition, after which the name is an ordinary identifier again. The main uses: overriding a library's macro, and <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">cleanup after a temporary macro</span> — which is exactly what the X-macro pattern requires.</p><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);">5. X-macros: one list, many expansions</h3><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">A genuinely elegant advanced pattern. Put a list in a file, then include it repeatedly with different definitions of <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">X</code>:</p><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-cm">/* colours.def — the single source of truth */</span><span class="js-id">X</span><span class="js-op">(</span><span class="js-id">RED</span><span class="js-op">,</span> 0xFF0000<span class="js-op">)</span><span class="js-id">X</span><span class="js-op">(</span><span class="js-id">GREEN</span><span class="js-op">,</span> 0x00FF00<span class="js-op">)</span><span class="js-id">X</span><span class="js-op">(</span><span class="js-id">BLUE</span><span class="js-op">,</span> 0x0000FF<span class="js-op">)</span></code></pre></div></div></div><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;"><span class="js-cm">/* the enum */</span><span class="js-id">typedef</span> <span class="js-id">enum</span> <span class="js-op">{</span>#<span class="js-id">define</span> <span class="js-id">X</span><span class="js-op">(</span><span class="js-id">name</span><span class="js-op">,</span> <span class="js-id">value</span><span class="js-op">)</span> <span class="js-id">COLOR_</span>##<span class="js-id">name</span><span class="js-op">,</span>#<span class="js-id">include</span> <span class="js-str">"colours.def"</span>#<span class="js-id">undef</span> <span class="js-id">X</span><span class="js-op">}</span> <span class="js-id">Color</span><span class="js-op">;</span>
<span class="js-cm">/* the name lookup */</span><span class="js-kw">const</span> <span class="js-id">char</span> <span class="js-op">*</span><span class="js-id">colorName</span><span class="js-op">(</span><span class="js-id">Color</span> <span class="js-id">c</span><span class="js-op">)</span> <span class="js-op">{</span> <span class="js-kw">switch</span> <span class="js-op">(</span><span class="js-id">c</span><span class="js-op">)</span> <span class="js-op">{</span>#<span class="js-id">define</span> <span class="js-id">X</span><span class="js-op">(</span><span class="js-id">name</span><span class="js-op">,</span> <span class="js-id">value</span><span class="js-op">)</span> <span class="js-kw">case</span> <span class="js-id">COLOR_</span>##<span class="js-id">name</span><span class="js-op">:</span> <span class="js-kw">return</span> #<span class="js-id">name</span><span class="js-op">;</span>#<span class="js-id">include</span> <span class="js-str">"colours.def"</span>#<span class="js-id">undef</span> <span class="js-id">X</span> <span class="js-op">}</span> <span class="js-kw">return</span> <span class="js-str">"unknown"</span><span class="js-op">;}</span>
<span class="js-cm">/* the value table */</span><span class="js-kw">const</span> <span class="js-id">unsigned</span> <span class="js-id">long</span> <span class="js-id">colorValues</span>[] <span class="js-op">=</span> <span class="js-op">{</span>#<span class="js-id">define</span> <span class="js-id">X</span><span class="js-op">(</span><span class="js-id">name</span><span class="js-op">,</span> <span class="js-id">value</span><span class="js-op">)</span> <span class="js-id">value</span><span class="js-op">,</span>#<span class="js-id">include</span> <span class="js-str">"colours.def"</span>#<span class="js-id">undef</span> <span class="js-id">X</span><span class="js-op">};</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">One list, three generated structures, guaranteed to stay in sync.</span> Add a colour to <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">colours.def</code> and the enum, the name lookup, and the table all update together — the compiler catches any mismatch. This uses everything on this page at once: <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#include</code> for the list, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">##</code> to build identifiers, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#</code> to build strings, and <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#undef</code> for cleanup.</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">Note the file extension: <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">.def</code> (not <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">.h</code>) signals "this isn't a standalone header — it's meant to be included inside a macro definition."</p><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);">6. Commenting out a region safely</h3><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-kw">if</span> <span class="js-num">0</span> <span class="js-cm">/* disabled code, possibly containing comments */</span>#<span class="js-id">endif</span></code></pre></div></div></div><h3 class="mt-6 mb-2 font-semibold text-xl" data-streamdown="heading-3" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.075px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);">7. Guaranteeing a minimum language version</h3><div class="my-4 flex w-full flex-col gap-2 rounded-xl bg-sidebar p-2" data-language="c" data-streamdown="code-block" dir="ltr" style="border-width: medium; border-style: none; border-color: currentcolor; border-image: none; margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 7.5px; margin-block: 1rem 0.75rem; background: 0px 0px rgb(18, 18, 22); gap: 0px; --tw-space-y-reverse: 0; display: flex; width: 960px; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; content-visibility: auto; contain-intrinsic-size: auto 200px;"><div class="language-c" data-language="c" data-streamdown="code-block-body" dir="ltr" style="border: 1px solid rgb(47, 47, 55); padding: 0.625rem 0.75rem; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); border-radius: 0.5rem; font-size: 0.8125rem; line-height: 1.6; max-height: 400px;"><div class="code-card position-relative my-2">
<div class="code-card-actions">
<button type="button" class="btn-code-action copy-code-btn" onclick="copyCode(this)" title="Copy Code">
<i class="far fa-copy"></i>
</button>
<a href="/tools/c-compiler" target="_blank" class="btn-code-action run-code-btn" title="Run Online">
<i class="fas fa-play"></i>
</a>
</div>
<pre class="language-c bg-[var(--sdm-bg,inherit)] dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit))] code-box" style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text; background: 0px 0px; --sdm-bg: transparent; --sdm-fg: inherit;"><code style="border-width: 0px; border-style: solid; border-color: rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 1em; user-select: text;">#<span class="js-kw">if</span> <span class="js-id">defined</span><span class="js-op">(</span><span class="js-id">__STDC_VERSION__</span><span class="js-op">)</span> <span class="js-op">&amp;&amp;</span> <span class="js-id">__STDC_VERSION__</span> <span class="js-op">&gt;=</span> 199901L <span class="js-cm">/* C99 features available */</span>#<span class="js-kw">else</span> #<span class="js-id">error</span> <span class="js-str">"C99 or later is required"</span>#<span class="js-id">endif</span></code></pre></div></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><em style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);">(Suggested image: the X-macro pattern as one list fanning out into three generated structures — enum, switch, table — with a "stay in sync automatically" label)</em></p><hr class="my-6" data-streamdown="horizontal-rule" style="border-width: 1px 0px 0px; border-style: solid; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); height: 0px; margin-block: 1rem 0.75rem; --tw-space-y-reverse: 0; font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><h2 class="mt-6 mb-2 font-semibold text-2xl" data-streamdown="heading-2" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1.125rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.105469px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);">What the Preprocessor Cannot Do</h2><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">Understanding the limits explains why some problems have no macro solution:</p><div class="my-4 flex flex-col gap-2 rounded-lg bg-sidebar p-2" data-streamdown="table-wrapper" style="border: 0.8px solid rgb(47, 47, 55); margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); max-width: 100%; border-radius: 0.5rem; margin-block: 1rem 0.75rem; overflow: hidden; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(24, 25, 27); gap: 0px; --tw-space-y-reverse: 0; display: flex; flex-direction: column; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px;"><div class="border-collapse" style="border: 1px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); border-collapse: collapse; border-radius: 5.5px; background-color: rgb(18, 18, 22); max-height: 300px;"><table class="w-full divide-y divide-border" data-streamdown="table" style="border-width: 0px; border-color: inherit; margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); text-indent: 0px; min-width: 100%; width: 951.2px;"><thead class="bg-muted/80" data-streamdown="table-header" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0; background-color: oklab(0.252138 0.000131465 -0.00581433 / 0.8);"><tr class="" data-streamdown="table-row" style="border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);"><th class="whitespace-nowrap px-4 py-2 text-left font-semibold text-sm" data-streamdown="table-header-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px; --tw-font-weight: 600; white-space: nowrap;">Cannot</th><th class="whitespace-nowrap px-4 py-2 text-left font-semibold text-sm" data-streamdown="table-header-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px; --tw-font-weight: 600; white-space: nowrap;">Why</th><th class="whitespace-nowrap px-4 py-2 text-left font-semibold text-sm" data-streamdown="table-header-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px; --tw-font-weight: 600; white-space: nowrap;">Consequence</th></tr></thead><tbody class="divide-y divide-border" data-streamdown="table-body" style="border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);"><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Type check anything</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">It operates on text, not types</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">A macro accepts any argument, valid or not</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Respect scope</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">It has no concept of blocks or functions</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">A <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#define</code> inside a function affects the rest of the file</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Understand C syntax</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">It works on tokens</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">A macro can produce syntactically broken code</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Evaluate <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">sizeof</code>, casts, casts to a type</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Those are compile-time language operations, not preprocessor ones</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#if sizeof(int) == 4</code> is an error</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Do floating-point arithmetic in <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#if</code></td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">The preprocessor is integer-only</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#if VERSION &gt; 2.5</code> fails</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Loop</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">No iteration construct exists</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Repetition needs X-macros or generated code</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Define a variable</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Macros aren't names in the language</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">No address, no debugger visibility</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">See inside string literals</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Strings are tokens, not scanned for names</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Macro names in strings stay literal</td></tr><tr class="" data-streamdown="table-row" style="border-width: 0px 0px 0.8px; border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-divide-y-reverse: 0;"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Appear in a debugger</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Macros don't exist after preprocessing</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Step through the <em style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);">expanded</em> code or the <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">.i</code> file</td></tr><tr class="" data-streamdown="table-row" style="border-color: rgb(47, 47, 55); border-image: none; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);"><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">Be recursive in a useful way</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">A macro can't expand itself</td><td class="px-4 py-2 text-sm" data-streamdown="table-cell" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-inline: 15px; padding-block: 7.5px; font-size: 13px; line-height: 18.75px;">(Recursive <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#include</code> tricks exist but are not a serious tool)</td></tr></tbody></table></div></div><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">The practical takeaway:</span> when a macro keeps getting more complicated — layers of parentheses, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">##</code> gymnastics, argument-count tricks — that's the signal to write a function, a <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">static inline</code> helper, or a code generator instead. Macros are a blunt instrument and they don't get sharper with effort.</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><em style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);">(Suggested image: the "cannot" list as a boundary diagram — preprocessor capabilities on one side, compiler capabilities on the other, with the shared token stream in the middle)</em></p><hr class="my-6" data-streamdown="horizontal-rule" style="border-width: 1px 0px 0px; border-style: solid; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); height: 0px; margin-block: 1rem 0.75rem; --tw-space-y-reverse: 0; font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><h2 class="mt-6 mb-2 font-semibold text-2xl" data-streamdown="heading-2" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1.125rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.105469px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);">Common Mistakes</h2><ol class="list-inside list-decimal whitespace-normal [li_&amp;]:pl-6" data-streamdown="ordered-list" style="border: 0px solid rgb(47, 47, 55); margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); list-style: outside decimal; padding-inline-start: 1.375rem; margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Missing parentheses around macro parameters</span> — <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#define SQUARE(x) x*x</code> gives <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">SQUARE(1+2) == 5</code>, verified above. Wrap every parameter.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Missing parentheses around the whole macro body</span> — <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">DOUBLE(x)</code> as <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">(x)+(x)</code> breaks when composed: <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">2 * DOUBLE(3)</code> becomes <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">9</code>, not <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">12</code>.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Passing arguments with side effects</span> — <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">MAX(i++, j++)</code> incremented <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">j</code> <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">twice</span> and performed 3 increments total, verified above. Undefined behavior, invisible at the call site.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Writing a multi-statement macro without <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">do { } while (0)</code></span> — an <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">if</code> without braces followed by <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">;</code> orphans a later <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">else</code> and fails to compile.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">A space between the macro name and <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">(</code></span> — <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#define F(x)</code> is function-like; <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#define F (x)</code> is an object-like macro with body <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">(x)</code>. Completely different.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Forgetting include guards</span> — the second inclusion produces duplicate definitions; verified as 2 copies of <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">typedef struct</code> instead of 1.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Guard-name collisions across headers</span> — the second header's contents silently vanish because the first already defined the guard name.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Using a leading underscore in a guard name</span> — reserved for the implementation.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Assuming <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#pragma once</code> is portable</span> — it's a widely supported extension, not standard, and it keys on file path, so two paths to one file can still double-include.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Expecting macros to respect scope</span> — a <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#define</code> inside a function body still applies for the rest of the file.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Expecting macro names to expand inside string literals</span> — they don't; <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">"VERSION"</code> stays literal.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Using a runtime expression in <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#if</code></span> — <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#if</code> needs a <em style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);">constant integer</em> expression; no <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">sizeof</code>, no casts, no functions, no floats.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Relying on undefined identifiers being errors in <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#if</code></span> — they evaluate to <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">0</code>, silently. Enable <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">-Wundef</code>.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Writing <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#ifdef A &amp;&amp; B</code></span> — invalid; use <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#if defined(A) &amp;&amp; defined(B)</code>.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Trailing spaces after a <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">\</code> line continuation</span> — breaks the macro with a confusing error at an unrelated line.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Omitting the semicolon conventions</span> — an object-like macro shouldn't carry one (<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#define MAX 100;</code> breaks <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">arr[MAX];</code>), and function-like macros are used <em style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);">with</em> one.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Passing a comma-containing argument</span> — <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">MAX(a ? b, c : d, e)</code> splits wrongly, because the preprocessor splits on commas and doesn't understand the ternary. Wrap it: <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">MAX((a ? b : c), e)</code>.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Using macros where a function would be safer</span> — no type checking, no debugging, and double evaluation are all avoided by a function or <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">static inline</code>.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Redefining a macro with a different body</span> — a diagnostic (or silent use of the first definition) depending on the compiler.</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Confusing <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#define</code> with assignment</span> — there's no storage, no address, and no runtime existence. <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">&amp;MAX</code> and <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">MAX++</code> are errors.</li></ol><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><em style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);">(Suggested image: "20 Preprocessor Mistakes" checklist — with #1, #3, and #5 highlighted as the ones that produce silently wrong results)</em></p><hr class="my-6" data-streamdown="horizontal-rule" style="border-width: 1px 0px 0px; border-style: solid; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); height: 0px; margin-block: 1rem 0.75rem; --tw-space-y-reverse: 0; font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><h2 class="mt-6 mb-2 font-semibold text-2xl" data-streamdown="heading-2" dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 22.5px 0px 7.5px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-size: 1.125rem; line-height: 1.35; --tw-space-y-reverse: 0; letter-spacing: -0.105469px; --tw-font-weight: 600; margin-block: 1.25rem 0.75rem; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; background-color: rgb(18, 18, 22);">Final Thoughts</h2><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">The preprocessor is a text editor that runs before your compiler. Everything about it follows from that one fact: <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#include</code> pastes a file, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#define</code> substitutes text, conditionals remove text, and none of it knows or cares about C's types, scope, or syntax.</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">Once you internalize that, the whole topic becomes predictable:</p><ul class="list-inside list-disc whitespace-normal [li_&amp;]:pl-6" data-streamdown="unordered-list" style="border: 0px solid rgb(47, 47, 55); margin: 0px; padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); list-style: outside disc; padding-inline-start: 1.375rem; margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);"><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#include</code> is textual insertion</span> — which is why double inclusion is a problem, and why include guards (or <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#pragma once</code>) are mandatory</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Macros are text substitution</span> — which is why parentheses are non-negotiable, why arguments can be evaluated more than once, and why <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#define SQUARE(x) x*x</code> gives <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">5</code> for <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">SQUARE(1+2)</code></li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Multi-statement macros need <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">do { } while (0)</code></span> so they behave as one statement everywhere</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;">Conditional compilation removes code before the compiler sees it</span> — the tool for platform differences, debug builds, and feature flags</li><li class="py-1 [&amp;&gt;p]:inline" data-streamdown="list-item" dir="ltr" style="border: 0px solid rgb(47, 47, 55); padding: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); padding-block: 0.125rem;"><span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">__FILE__</code>, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">__LINE__</code>, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">__DATE__</code>, and <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">__VA_ARGS__</code> cost nothing</span> and are already there — use them for diagnostics</li></ul><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">The judgement that matters most is knowing when to <em style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5);">stop</em>. Macros are powerful precisely because they're unconstrained — and that's also why they're dangerous. Use them for what only they can do: constants, conditional compilation, and the handful of genuinely textual operations like <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">#</code>, <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">##</code>, and <code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">sizeof</code>-based idioms. For everything else, write a function and let the compiler help you.</p><p dir="ltr" style="border: 0px solid rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); margin-block: 0px 0.75rem; --tw-space-y-reverse: 0; color: rgb(252, 252, 253); font-family: &quot;Inter Variable&quot;, sans-serif; font-size: 13px; background-color: rgb(18, 18, 22);">And when a macro misbehaves, remember the debugging move from the top of this page: <span class="font-semibold" data-streamdown="strong" style="border: 0px solid rgb(47, 47, 55); outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); --tw-font-weight: 600; font-weight: 600;"><code class="rounded bg-muted px-1.5 py-0.5 font-mono text-sm" data-streamdown="inline-code" dir="ltr" style="border-width: 0px; border-color: rgb(47, 47, 55); margin: 0px; outline-color: oklab(0.51773 0.045283 -0.122431 / 0.5); font-family: &quot;Geist Mono Variable&quot;, ui-monospace, SFMono-Regular, Menlo, Consolas, &quot;Liberation Mono&quot;, monospace; font-feature-settings: normal; font-variation-settings: normal; font-size: 0.8125rem; user-select: text; border-radius: 0.25rem; background-color: rgb(33, 34, 37); padding-inline: 5.625px; padding-block: 1.875px; line-height: 18.75px; padding: 0.1em 0.35em;">gcc -E</code></span>. The answer is always visible in the expanded translation unit — usually in five seconds.</p>

Code Example

#include <stdio.h>

#define PLATFORM_LINUX 1

int main() {
    #ifdef PLATFORM_LINUX
    printf("Compiling for Linux Platform\
");
    #else
    printf("Compiling for Generic Platform\
");
    #endif
    return 0;
}

Interview Question & Tips

Q: What compiler command allows you to view the output of the preprocessor step in GCC?
A: `gcc -E filename.c`
Q: Does the preprocessor allocate memory or generate machine code?
A: No, it is strictly a text-manipulation tool that outputs modified C source code to the compiler.

Best Practices

Use `#pragma once` or standard include guards (`#ifndef HEADER_H ... #endif`) in every header file to prevent duplicate header inclusion.
Academic Standards & Verified Citations

This study reference for C Preprocessor Directives: How Source Code Is Prepared Before Compilation is curated and verified against recognized curriculum benchmarks, peer-reviewed textbooks, and official technical documentation:

C Programming