Search code examples
cmakeclang-tidy

clang-tidy can't find #include <cstddef>


I am running clang-tidy checks using cmake version 3.20.0-rc1 on Windows 10.
My project builds using GNU 8.3.0.
Sadly I get the error

error: 'cstddef' file not found [clang-diagnostic-error]
#include <cstddef>

clang-tidy info:

LLVM (http://llvm.org/):
LLVM version 12.0.0
Optimized build.
Default target: i686-pc-windows-msvc
Host CPU: skylake


Solution

  • [clang-diagnostic-error] is basically a compiler error coming from the clang backend.

    Clang-tidy needs an AST (abstract syntax tree) - your code has to be compileable by clang compiler in order to generate an AST. Only then will clang-tidy analyze your code.

    Get your code to compile by clang instead of GCC and you should find the source of your problem.