Lesson 47 of 50
cStatic Analysis with clang‑tidy
9 mins
Course progress94%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 47 of 50
c9 mins
Keep these ideas in mind as you work through the lesson.
clang‑tidy is a linter that checks C code for bugs, style, and modern practices.
Common checks:
readability-identifier-naming – enforce naming conventions.modernize-use-nullptr – (C++) not applicable, but modernize-* offers suggestions for C as well.bugprone-* – detect potential undefined behaviour.performance-* – recommend faster constructs.Typical command:
clang-tidy src/*.c -checks='*' -warnings-as-errors='*' -- -Iinclude
-- separates clang‑tidy options from compiler flags.src/main.c:12:5: warning: use of uninitialized variable 'x' [clang-analyzer-core.Uninitialized]
int result = x * 2;
^~~~
1 warning generated.