Author Topic: Is there any expectation or desire to compile Code::Blocks with clang/clang++  (Read 439 times)

Offline everSome

  • Multiple posting newcomer
  • *
  • Posts: 61
It might be useful to compile Code::Blocks with the clang compiler as the warnings and once in a while the errors exposed are somewhat different. What think ye?

Offline christo

  • Developer
  • Multiple posting newcomer
  • *****
  • Posts: 83
Looks like Morten is working on building C::B for clang/arm. Recent svn changs shows many fixes the warnings.

Offline blauzahn

  • Almost regular
  • **
  • Posts: 233
Even without actually compiling cb with llvm/clang you can benefit A LOT from its toolbox to find errors and dubious code.

1) Use the clangd_client cb-plugin. I only activate it temporarily, look at its findings and deactivate it afterwards due to its early stage.
2) Use clang-tidy as a "compiler" on any c++ project from within cb. Like with compiler warnings, clicking onto one jumps to the corresponding code line. This one I use very often.  I started using it with cb over 10 years ago.
3) Use scan-build from the commandline when building cb or any other project that compiles makefiles (e.g. via cmake). Gives a nice report.

Apart from llvm/clang I still recommend the cb-plugin for cppcheck.

The tools do have false positives. You can configure .clang-tidy. I disabled some warnings but in general I like to keep warnings on. At spots with false positives you can apply local suppressions (NOLINT, NOLINTNEXTLINE, cppcheck-suppress etc.). When using one of the tools for the first time on a larger codebase you might be flooded with warnings. Don't dispair. One strategy to attack the list systematically is to disable all but one type of warning. Fix those and proceed with the next type of warning. This might also happen after an update of one of the tools. A week ago, llvm forked clang-23 and started to provide packages for clang-24. The latter added a new check for [misc-const-correctness]. I like it.