Debugging & Toolchain · Interview question

What's the infamous Makefile tab error, and what is .PHONY for?

A strong answer

Make requires the command lines in a recipe to be indented with a literal tab character, not spaces. If you indent a recipe line with spaces, Make doesn't recognize it as a recipe and emits the cryptic *** missing separator. Stop. error, it's a rite of passage because editors that convert tabs to spaces silently introduce it. So recipes must start with a real tab. Separately, .PHONY declares targets that don't correspond to actual files, like all, clean, flash, test. Normally Make treats a target name as a filename and checks its timestamp; if a file named clean happened to exist in the directory, Make would consider the clean target "up to date" and skip its recipe entirely. Declaring .PHONY: clean all flash tells Make these are always-run actions regardless of any like-named file, so make clean always runs its rm commands. It also slightly speeds things up (Make doesn't stat for the file) and documents intent. Both are small but bite real projects: the tab error blocks the build outright, and a missing .PHONY causes a "make clean does nothing" mystery when a stray file shadows the target.

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

The Build Process & Makefiles

Automating compile-and-link and rebuilding only what changed: Make rules (target/prereq/recipe), pattern rules and variables, and auto-generated header dependencies that avoid stale builds.

More The Build Process & Makefiles questions

Browse all 472 interview questions
What's the infamous Makefile tab error, and what is .PHONY for? | EmbeddedPrep.io