Reading Compiler Output
beginner14 min readLesson 68 of 148
Warnings are the compiler handing you the bug report before the crash.
Compile with warnings ON, always
gcc -std=c23 -Wall -Wextra -o app main.c
-Wall -Wextra is the default posture for this course's challenges too: the
build warnings you see are the same ones the grader sees.
The warnings that mark real bugs
unused variableโ you computed something and never used it: often a forgotten stepuninitializedโ the value is read before any assignment: undefined behavior waiting to happenwrong format specifierโprintf("%d", 3.14)prints garbage: the type and the format must agreecontrol reaches end of non-void functionโ a code path returns nothingassignment in conditionโif (x = 5)assigns, then tests 5; you probably meant==
Read errors bottom-up
The FIRST error is the real one; later errors are often its shockwaves. Fix
the first, recompile, repeat. And read the caret line (^) โ the compiler
points at the exact token it choked on.
Error vs warning
A warning compiles anyway โ the program runs, wrongly. The discipline:
treat every warning as a bug. -Werror (turn warnings into errors) is
how professional builds enforce it.