Programming Fundamentals · Interview question

Why turn on -Wall -Wextra and -Werror?

A strong answer

-Wall -Wextra enables most of the compiler's warnings, diagnostics for code that's legal C but suspicious: uninitialized variable use, signed/unsigned comparisons, unused variables, suspicious operator precedence, missing return statements. Each warning flags a likely bug. -Werror upgrades every warning into an error that stops the build, which forces you to deal with them immediately instead of letting them accumulate. The accumulation problem is real: a project with 200 warnings effectively has 200 invisible warnings, because nobody reads them. With -Werror, every new warning is an immediate problem with fresh context. The combination catches a significant fraction of bugs at compile time, far cheaper than catching them at runtime, and orders of magnitude cheaper than catching them in production. Most professional C projects use both flags from day one.

What a weak answer sounds like

You know the answer. Do you know what gets you dinged?

Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.

From the lesson

Errors & Debugging

Errors are messages from the compiler trying to help. Learn to read them, distinguish the three kinds of bugs, and build the mindset that turns debugging from frustration into a skill.

More Errors & Debugging questions

Browse all 472 interview questions
Why turn on -Wall -Wextra and -Werror? | EmbeddedPrep.io