💡 What does “Compilation” mean?
When you write a program in C, the computer doesn’t understand that human-readable code directly. It only understands machine code (0s and 1s).
So we need a compiler that translates our .c file into machine-readable format (executable file).
Think of it like:
📝 Your C code → 🗣️ Translator (Compiler) → 🖥️ Computer-readable code
🛤️ Step-by-Step Compilation Flow:
<div class="infographic-cflow">
<style>
.infographic-cflow {
--ink: #1a1a1a;
--ink-soft: #5c5c5c;
--paper: #ffffff;
--paper-alt: #f0ece4;
--accent: #2563eb;
--accent-soft:#e3ebfd;
--line: #ddd6c9;
--code-bg: #1e1e2e;
--code-text: #d4d4e0;
--syn-preproc: #569cd6;
--syn-keyword: #c586c0;
--syn-func: #dcdcaa;
--syn-string: #ce9178;
--syn-comment: #6a9955;
}
.infographic-cflow[data-theme="dark"] {
--ink: #e8e6e1;
--ink-soft: #9a968c;
--paper: #121212;
--paper-alt: #1e1e26;
--accent: #5b8def;
--accent-soft:#202942;
--line: #2c313d;
--code-bg: #0d0d14;
--code-text: #d4d4e0;
}
.infographic-cflow {
box-sizing: border-box;
max-width: 720px;
margin: 0 auto;
background: var(--paper);
color: var(--ink);
font-family: 'Inter', -apple-system, sans-serif;
padding: 0 clamp(1.25rem, 5vw, 3rem);
}
.infographic-cflow *, .infographic-cflow *::before, .infographic-cflow *::after {
box-sizing: border-box;
}
.infographic-cflow h1 {
font-family: 'Fraunces', Georgia, serif;
font-weight: 600;
font-size: clamp(1.6rem, 4vw, 2.2rem);
margin: 2rem 0 0.25rem;
}
.infographic-cflow .subhead {
color: var(--ink-soft);
font-size: 0.95rem;
margin-bottom: 1rem;
}
.infographic-cflow .controls {
display: flex;
align-items: center;
gap: 0.75rem;
margin-bottom: 2rem;
}
.infographic-cflow .play-btn {
all: unset;
cursor: pointer;
background: var(--accent);
color: #fff;
font-size: 0.85rem;
font-weight: 600;
padding: 0.55rem 1.1rem;
border-radius: 6px;
display: inline-flex;
align-items: center;
gap: 0.4rem;
transition: opacity 0.15s, transform 0.15s;
}
.infographic-cflow .play-btn:hover { opacity: 0.88; }
.infographic-cflow .play-btn:active { transform: scale(0.96); }
.infographic-cflow .play-btn:disabled { opacity: 0.5; cursor: default; }
.infographic-cflow .play-hint {
font-size: 0.8rem;
color: var(--ink-soft);
font-style: italic;
}
.infographic-cflow .flow {
position: relative;
padding-left: 3.6rem;
}
.infographic-cflow .flow-spine {
position: absolute;
left: 1.55rem;
top: 1.8rem;
bottom: 1.8rem;
width: 2px;
background: var(--line);
}
.infographic-cflow .flow-dot {
position: absolute;
left: 1.55rem;
top: 1.8rem;
width: 12px;
height: 12px;
margin-left: -5px;
border-radius: 50%;
background: var(--accent);
box-shadow: 0 0 0 4px var(--accent-soft);
transition: top 0.5s cubic-bezier(.4,0,.2,1);
opacity: 0;
z-index: 2;
}
.infographic-cflow .flow-dot.is-visible { opacity: 1; }
.infographic-cflow .flow-step {
position: relative;
margin-bottom: 0.7rem;
}
.infographic-cflow .step-icon {
position: absolute;
left: -3.6rem;
top: 0.65rem;
width: 2.9rem;
height: 2.9rem;
border-radius: 50%;
background: var(--paper);
border: 2px solid var(--line);
font-size: 1.3rem;
display: flex;
align-items: center;
justify-content: center;
z-index: 1;
transition: border-color 0.25s, background 0.25s, transform 0.35s;
}
.infographic-cflow .flow-step.is-active .step-icon {
border-color: var(--accent);
background: var(--accent-soft);
animation: cflow-pop 0.5s ease;
}
@keyframes cflow-pop {
0% { transform: scale(1); }
40% { transform: scale(1.22); }
100% { transform: scale(1); }
}
.infographic-cflow .step-btn {
all: unset;
display: block;
width: 100%;
cursor: pointer;
padding: 0.9rem 1.1rem;
border: 1px solid var(--line);
border-radius: 10px;
background: var(--paper);
transition: border-color 0.25s, background 0.25s, box-shadow 0.25s, transform 0.25s;
}
.infographic-cflow .flow-step.is-active .step-btn {
border-color: var(--accent);
background: var(--accent-soft);
box-shadow: 0 4px 14px -6px rgba(37, 99, 235, 0.35);
transform: translateX(2px);
}
.infographic-cflow .step-head {
display: flex;
align-items: center;
gap: 0.6rem;
}
.infographic-cflow .step-title {
font-weight: 600;
font-size: 1.02rem;
}
.infographic-cflow .step-sub {
font-family: 'IBM Plex Mono', monospace;
font-size: 0.78rem;
color: var(--ink-soft);
}
.infographic-cflow .chevron {
margin-left: auto;
color: var(--ink-soft);
font-size: 0.75rem;
transition: transform 0.2s;
}
.infographic-cflow .flow-step.is-open .chevron {
transform: rotate(90deg);
}
.infographic-cflow .step-detail {
display: grid;
grid-template-rows: 0fr;
transition: grid-template-rows 0.3s ease;
}
.infographic-cflow .step-detail-inner {
overflow: hidden;
font-size: 0.88rem;
color: var(--ink-soft);
line-height: 1.5;
}
.infographic-cflow .flow-step.is-open .step-detail {
grid-template-rows: 1fr;
margin-top: 0.6rem;
}
.infographic-cflow .step-detail code {
background: var(--code-bg);
color: var(--code-text);
padding: 0.1rem 0.4rem;
border-radius: 4px;
font-family: 'IBM Plex Mono', monospace;
font-size: 0.85em;
}
/* Reusable animated before/after code demo (Preprocessing, Compilation, Assembly) */
.infographic-cflow .stage-demo {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.infographic-cflow .stage-code {
background: var(--code-bg);
color: var(--code-text);
border-radius: 8px;
padding: 0.85rem 1rem;
font-family: 'IBM Plex Mono', monospace;
font-size: 0.8rem;
opacity: 0;
}
.infographic-cflow .stage-code .code-line {
white-space: pre;
line-height: 1.75;
}
.infographic-cflow .stage-code .code-line.indent {
padding-left: 1.2rem;
}
.infographic-cflow .stage-arrow {
align-self: center;
font-size: 0.78rem;
color: var(--ink-soft);
opacity: 0;
}
.infographic-cflow .flow-step.is-open .stage-before {
animation: cflow-fade-in 0.4s ease 0.1s both;
}
.infographic-cflow .flow-step.is-open .stage-arrow {
animation: cflow-fade-in 0.4s ease 0.55s both, cflow-bob 1s ease 1s 2;
}
.infographic-cflow .flow-step.is-open .stage-after {
animation: cflow-fade-in 0.4s ease 0.95s both;
}
.infographic-cflow .glow-a, .infographic-cflow .glow-b {
border-radius: 3px;
padding: 0 0.15rem;
}
.infographic-cflow .flow-step.is-open .glow-a {
animation: cflow-token-glow 0.9s ease 0.3s both;
}
.infographic-cflow .flow-step.is-open .glow-b {
animation: cflow-token-glow 0.9s ease 1.05s both;
}
@keyframes cflow-fade-in {
from { opacity: 0; transform: translateY(6px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes cflow-bob {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(3px); }
}
@keyframes cflow-token-glow {
0% { background: transparent; }
35% { background: var(--accent); color: #fff; }
100% { background: transparent; }
}
/* Your Code stage: staggered line-by-line reveal */
.infographic-cflow .stage-code.stage-typed .code-line {
opacity: 0;
}
.infographic-cflow .flow-step.is-open .stage-typed {
opacity: 1;
animation: none;
}
.infographic-cflow .flow-step.is-open .stage-typed .code-line {
animation: cflow-fade-in 0.35s ease both;
}
.infographic-cflow .flow-step.is-open .stage-typed .code-line:nth-child(1) { animation-delay: 0.1s; }
.infographic-cflow .flow-step.is-open .stage-typed .code-line:nth-child(2) { animation-delay: 0.28s; }
.infographic-cflow .flow-step.is-open .stage-typed .code-line:nth-child(3) { animation-delay: 0.46s; }
.infographic-cflow .flow-step.is-open .stage-typed .code-line:nth-child(4) { animation-delay: 0.64s; }
.infographic-cflow .flow-step.is-open .stage-typed .code-line:nth-child(5) { animation-delay: 0.82s; }
.infographic-cflow .flow-step.is-open .stage-typed .code-line:nth-child(6) { animation-delay: 1.0s; }
/* Linking stage: object files merging into one executable */
.infographic-cflow .link-demo {
display: flex;
align-items: center;
justify-content: center;
gap: 0.6rem;
flex-wrap: wrap;
padding: 0.75rem 0.25rem;
}
.infographic-cflow .link-box {
font-family: 'IBM Plex Mono', monospace;
font-size: 0.78rem;
background: var(--paper-alt);
border: 1px solid var(--line);
border-radius: 6px;
padding: 0.5rem 0.7rem;
opacity: 0;
transform: scale(0.85);
}
.infographic-cflow .link-plus {
color: var(--ink-soft);
opacity: 0;
font-size: 0.9rem;
}
.infographic-cflow .link-result {
font-family: 'IBM Plex Mono', monospace;
font-size: 0.85rem;
font-weight: 600;
background: var(--accent-soft);
border: 1px solid var(--accent);
color: var(--accent);
border-radius: 6px;
padding: 0.55rem 0.9rem;
opacity: 0;
transform: scale(0.7);
}
.infographic-cflow .flow-step.is-open .link-box,
.infographic-cflow .flow-step.is-open .link-plus {
animation: cflow-merge-in 0.4s ease both;
}
.infographic-cflow .flow-step.is-open .link-result {
animation: cflow-merge-pop 0.5s ease both;
}
@keyframes cflow-merge-in {
from { opacity: 0; transform: scale(0.85) translateY(4px); }
to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes cflow-merge-pop {
0% { opacity: 0; transform: scale(0.6); }
60% { opacity: 1; transform: scale(1.08); }
100% { opacity: 1; transform: scale(1); }
}
/* Executable stage: terminal run animation */
.infographic-cflow .term-window {
background: var(--code-bg);
border-radius: 8px;
padding: 0.85rem 1rem;
font-family: 'IBM Plex Mono', monospace;
font-size: 0.82rem;
line-height: 1.8;
}
.infographic-cflow .term-prompt {
color: #7fdb8a;
}
.infographic-cflow .term-cmd {
color: var(--code-text);
opacity: 0;
}
.infographic-cflow .flow-step.is-open .term-cmd {
animation: cflow-fade-in 0.3s ease 0.1s both;
}
.infographic-cflow .term-output {
display: inline-block;
overflow: hidden;
white-space: nowrap;
width: 0;
color: var(--code-text);
vertical-align: bottom;
}
.infographic-cflow .flow-step.is-open .term-output {
animation: cflow-type 0.7s steps(9, end) 0.55s forwards;
}
.infographic-cflow .term-cursor {
display: inline-block;
width: 7px;
height: 1em;
background: var(--code-text);
vertical-align: text-bottom;
margin-left: 2px;
opacity: 0;
}
.infographic-cflow .flow-step.is-open .term-cursor {
animation: cflow-fade-in 0.1s ease 0.55s both, cflow-blink 1s step-end 1.25s infinite;
}
@keyframes cflow-type {
from { width: 0; }
to { width: 4.6em; }
}
@keyframes cflow-blink {
0%, 100% { opacity: 1; }
50% { opacity: 0; }
}
.infographic-cflow .arrow-down {
position: absolute;
left: -2.15rem;
bottom: -0.62rem;
color: var(--line);
font-size: 0.85rem;
z-index: 1;
transition: color 0.25s, transform 0.25s;
}
.infographic-cflow .arrow-down.is-flowing {
color: var(--accent);
animation: cflow-nudge 0.6s ease;
}
@keyframes cflow-nudge {
0% { transform: translateY(0); }
50% { transform: translateY(4px); }
100% { transform: translateY(0); }
}
.infographic-cflow .takeaway {
border-top: 1px solid var(--line);
padding: 1.25rem 0 2rem;
font-size: 0.95rem;
color: var(--ink-soft);
margin-top: 1.5rem;
}
.infographic-cflow .takeaway strong {
color: var(--ink);
}
@media (prefers-reduced-motion: reduce) {
.infographic-cflow * {
transition: none !important;
animation: none !important;
}
}
</style>
<h1>⚙️ Compilation Flow of a C Program</h1>
<p class="subhead">One source file, four transformations, one executable.</p>
<div class="controls">
<button class="play-btn" id="cflow-play">▶ Play through</button>
<span class="play-hint">or click any stage below</span>
</div>
<div class="flow" id="cflow-list">
<div class="flow-spine"></div>
<div class="flow-dot" id="cflow-dot"></div>
<div class="flow-step" data-step="0">
<div class="step-icon">📝</div>
<button class="step-btn">
<div class="step-head">
<span class="step-title">Your Code</span>
<span class="step-sub">program.c</span>
<span class="chevron">▶</span>
</div>
<div class="step-detail"><div class="step-detail-inner">
<div class="stage-code stage-typed"><div class="code-line"><span class="syn-preproc">#include <stdio.h></span></div><div class="code-line"><span class="syn-preproc">#define</span> PI 3.14</div><div class="code-line"> </div><div class="code-line"><span class="syn-keyword">int</span> <span class="syn-func">main</span>() {</div><div class="code-line indent"><span class="syn-func">printf</span>(<span class="syn-string">"%f"</span>, PI);</div><div class="code-line">}</div></div>
</div></div>
</button>
<span class="arrow-down">▼</span>
</div>
<div class="flow-step" data-step="1">
<div class="step-icon">#️⃣</div>
<button class="step-btn">
<div class="step-head">
<span class="step-title">Preprocessing</span>
<span class="chevron">▶</span>
</div>
<div class="step-detail"><div class="step-detail-inner">
<div class="stage-demo">
<div class="stage-code stage-before"><div class="code-line"><span class="syn-preproc">#include <stdio.h></span></div><div class="code-line"><span class="syn-preproc">#define</span> PI 3.14</div><div class="code-line"> </div><div class="code-line"><span class="syn-keyword">int</span> <span class="syn-func">main</span>() {</div><div class="code-line indent"><span class="syn-func">printf</span>(<span class="syn-string">"%f"</span>, <span class="glow-a">PI</span>);</div><div class="code-line">}</div></div>
<div class="stage-arrow">⬇ preprocessor expands this ⬇</div>
<div class="stage-code stage-after"><div class="code-line syn-comment">// contents of stdio.h inserted here</div><div class="code-line"> </div><div class="code-line"><span class="syn-keyword">int</span> <span class="syn-func">main</span>() {</div><div class="code-line indent"><span class="syn-func">printf</span>(<span class="syn-string">"%f"</span>, <span class="glow-b">3.14</span>);</div><div class="code-line">}</div></div>
</div>
</div></div>
</button>
<span class="arrow-down">▼</span>
</div>
<div class="flow-step" data-step="2">
<div class="step-icon">⚙️</div>
<button class="step-btn">
<div class="step-head">
<span class="step-title">Compilation</span>
<span class="chevron">▶</span>
</div>
<div class="step-detail"><div class="step-detail-inner">
<div class="stage-demo">
<div class="stage-code stage-before"><div class="code-line"><span class="syn-keyword">int</span> <span class="syn-func">main</span>() {</div><div class="code-line indent"><span class="syn-func">printf</span>(<span class="syn-string">"%f"</span>, 3.14);</div><div class="code-line indent"><span class="syn-keyword">return</span> 0;</div><div class="code-line">}</div></div>
<div class="stage-arrow">⬇ compiler translates to assembly ⬇</div>
<div class="stage-code stage-after"><div class="code-line">main:</div><div class="code-line indent">push rbp</div><div class="code-line indent">mov rbp, rsp</div><div class="code-line indent">movsd xmm0, .LC0</div><div class="code-line indent">call printf</div><div class="code-line indent">ret</div></div>
</div>
</div></div>
</button>
<span class="arrow-down">▼</span>
</div>
<div class="flow-step" data-step="3">
<div class="step-icon">🔩</div>
<button class="step-btn">
<div class="step-head">
<span class="step-title">Assembly</span>
<span class="chevron">▶</span>
</div>
<div class="step-detail"><div class="step-detail-inner">
<div class="stage-demo">
<div class="stage-code stage-before"><div class="code-line">main:</div><div class="code-line indent">push rbp</div><div class="code-line indent">mov rbp, rsp</div><div class="code-line indent">call printf</div><div class="code-line indent">ret</div></div>
<div class="stage-arrow">⬇ assembler encodes to machine code ⬇</div>
<div class="stage-code stage-after"><div class="code-line">program.o</div><div class="code-line">55 48 89 e5 f2 0f 10 05</div><div class="code-line">00 00 00 00 e8 00 00 00</div><div class="code-line">00 b8 00 00 00 00 c3</div></div>
</div>
</div></div>
</button>
<span class="arrow-down">▼</span>
</div>
<div class="flow-step" data-step="4">
<div class="step-icon">🔗</div>
<button class="step-btn">
<div class="step-head">
<span class="step-title">Linking</span>
<span class="chevron">▶</span>
</div>
<div class="step-detail"><div class="step-detail-inner">
<div class="link-demo">
<span class="link-box" style="animation-delay:0.1s">program.o</span>
<span class="link-plus" style="animation-delay:0.3s">+</span>
<span class="link-box" style="animation-delay:0.45s">libc.a</span>
<span class="link-plus" style="animation-delay:0.65s">=</span>
<span class="link-result" style="animation-delay:1.05s">a.out</span>
</div>
</div></div>
</button>
<span class="arrow-down">▼</span>
</div>
<div class="flow-step" data-step="5">
<div class="step-icon">🚀</div>
<button class="step-btn">
<div class="step-head">
<span class="step-title">Executable</span>
<span class="step-sub">program.exe / a.out</span>
<span class="chevron">▶</span>
</div>
<div class="step-detail"><div class="step-detail-inner">
<div class="term-window">
<span class="term-prompt">$</span> <span class="term-cmd">./a.out</span><br>
<span class="term-output">3.140000</span><span class="term-cursor"></span>
</div>
</div></div>
</button>
</div>
</div>
<p class="takeaway"><strong>Four stages, one file in, one file out</strong> — every C program takes this exact path before it can run.</p>
</div>
<script>
(function () {
const wrapper = document.currentScript.closest('.infographic-cflow')
|| document.querySelector('.infographic-cflow');
const bodyAttr = document.body.getAttribute('data-darkmode');
let dark;
if (bodyAttr === 'true') {
dark = true;
} else if (bodyAttr === 'false') {
dark = false;
} else {
const match = document.cookie.match(/(?:^|;\s*)darkMode=([^;]+)/);
dark = match ? match[1] === 'true' : false;
}
if (dark) wrapper.setAttribute('data-theme', 'dark');
const steps = Array.from(wrapper.querySelectorAll('.flow-step'));
const playBtn = wrapper.querySelector('#cflow-play');
const dot = wrapper.querySelector('#cflow-dot');
const list = wrapper.querySelector('#cflow-list');
let playing = false;
let timer = null;
function moveDotTo(step) {
const icon = step.querySelector('.step-icon');
const top = icon.offsetTop + icon.offsetHeight / 2 - list.offsetTop;
dot.style.top = top + 'px';
dot.classList.add('is-visible');
}
function flashArrowBefore(index) {
if (index > 0) {
const prevArrow = steps[index - 1].querySelector('.arrow-down');
if (prevArrow) {
prevArrow.classList.remove('is-flowing');
void prevArrow.offsetWidth;
prevArrow.classList.add('is-flowing');
}
}
}
function activate(step, index) {
steps.forEach(s => s.classList.remove('is-active'));
step.classList.add('is-active');
moveDotTo(step);
flashArrowBefore(index);
}
steps.forEach((step, index) => {
const btn = step.querySelector('.step-btn');
btn.addEventListener('click', () => {
if (playing) return;
const wasOpen = step.classList.contains('is-open');
steps.forEach(s => s.classList.remove('is-open'));
if (!wasOpen) {
step.classList.add('is-open');
activate(step, index);
} else {
steps.forEach(s => s.classList.remove('is-active'));
dot.classList.remove('is-visible');
}
});
});
function stopPlaying() {
playing = false;
clearTimeout(timer);
playBtn.disabled = false;
playBtn.textContent = '▶ Play through';
}
playBtn.addEventListener('click', () => {
if (playing) return;
playing = true;
playBtn.disabled = true;
playBtn.textContent = '⏸ Playing…';
steps.forEach(s => { s.classList.remove('is-open'); s.classList.remove('is-active'); });
let i = 0;
function next() {
if (i >= steps.length) {
stopPlaying();
return;
}
steps.forEach(s => s.classList.remove('is-open'));
steps[i].classList.add('is-open');
activate(steps[i], i);
steps[i].scrollIntoView({ block: 'nearest', behavior: 'smooth' });
i++;
timer = setTimeout(next, 1600);
}
next();
});
})();
</script>
</div>✅ Step 1: Preprocessing
📌 What happens?
All lines starting with
#(like#include,#define) are handled here.It’s like preparing all raw materials before starting construction.
🧱 Examples:
Replaces
#define PI 3.14with3.14Adds contents of
#include <stdio.h>at the top
🔧 Tool Used Internally: cpp (C PreProcessor)
✅ Step 2: Compilation
📌 What happens?
The preprocessed
.ifile is converted to Assembly language (.sfile).Assembly is low-level but still human-readable (like a bridge between C and binary).
🧱 Why this step matters?
Compiler checks for syntax errors (missing semicolons, wrong types, etc.)
Generates machine instructions for each line of code
🔧 Tool Used Internally: cc1 (GCC Compiler core)
✅ Step 3: Assembly
📌 What happens?
Converts
.sAssembly code into object code (machine code) but not complete yet.
🧱 Object files contain compiled code for each function, but without connecting to library functions like printf.
🔧 Tool Used Internally: as (Assembler)
✅ Step 4: Linking
📌 What happens?
Links your
.ofile with library files (like code forprintf,scanf, etc.)Produces a complete executable file that can run on the system
🧱 Library Linking:
Every time you use
printf(), it doesn’t exist in your codeIt’s part of the C standard library, so linker connects your code to those definitions
🔧 Tool Used Internally: ld (Linker)
🧪 Optional Step 5: Execution
📌 What happens?
You run the final executable using your OS
OS loads your program into memory and the CPU executes the instructions
🧱 You finally see output like:
Hello, World!🧱 GCC Compilation Stages and Output Files
When you compile C code with gcc, it goes through 4 major steps:
Step | Name | File Extension | What It Contains |
|---|---|---|---|
1 | Preprocessing |
| Expanded source code (macros, includes) |
2 | Compilation |
| Assembly code |
3 | Assembling |
| Machine code (object file) |
4 | Linking |
| Final executable |
🔍 Why You Don’t See These Files by Default
By default, when you run:
gcc program.cGCC:
Internally goes through all 4 steps
Deletes intermediate files (
.i,.s,.o)Only keeps the final output:
a.out(the executable)
You only see a.out unless you instruct GCC to stop at a specific step or keep other files.
📂 How to Generate and See These Files:
Purpose | Command | Output File |
|---|---|---|
Only Preprocess |
|
|
Only Compile to Assembly |
|
|
Only Assemble to Object |
|
|
Compile Full and Name It |
|
|
🧠 Extra Tip: View All Steps Verbosely
gcc -v program.cThis shows each internal stage of compilation.
🧪 Real Example using GCC/GNU Complier
GCC (GNU Compiler Collection) is a powerful open-source compiler developed by the GNU Project. It is widely used to compile programs written in C, C++, and other languages
Let’s say you have this file hello.c:
#include <stdio.h>
int main() {
printf("Hello, C!\\n");
return 0;
}🔧 You compile using:
gcc hello.c -o hello👉 This command internally does:
cpp hello.c → hello.i # Preprocess
cc1 hello.i → hello.s # Compile
as hello.s → hello.o # Assemble
ld hello.o → hello (exe) # LinkThen you run it:
./helloHello, C!❓ Why is this Important?
Understanding the compilation process helps you:
🧠 Concept | 🧾 Benefit |
|---|---|
🐞 Debugging | You can understand at which stage the error happened |
💡 Optimization | You can analyze object files and assembly for performance |
🔗 Linking Errors | Understand why you get errors like "undefined reference to |
🔍 Tool Use | Helps with static analysis, memory debugging, and build tools |
🧱 Large Projects | Crucial for writing |
💬 Final Tips
Use
E,S,cflags withgccto stop at different stages:gcc -E hello.c -o hello.i # Preprocess only gcc -S hello.c -o hello.s # Compile only gcc -c hello.c -o hello.o # Assemble onlyView assembly code using:
gcc -S hello.c cat hello.s