c++gccclangstatic-analysis

How can I run GCC/Clang for static analysis? (warnings only)


Without compiling code, I would like GCC or Clang to report warnings.
Is it possible to run the compiler for static analysis only?
I can't find a way to pass the compiler warning flags and tell it not to compile.

edit: just found that clang has a static analyser


Solution

  • Both GCC and Clang have an option -fsyntax-only that makes the compiler only perform syntax checking without any actual compilation.