9

We've tried to beautify our code a bit with clang-format tool.

In order to get unified result on all machines we've done clang-format --style=llvm --dump-config, which has been tuned a bit and stored into repo.

The issue is that clang 10 and 9 seem to provide us with different output for exactly the same code. I've seen changes in comments alignment only so far, but it still breaks the whole idea of getting code style consistent. Another issue is that clang 9 is unable to parse some settings dumped from v10.

Is there any way to insure consistent formatting across multiple versions of clang-format?

Roman
  • 1,396
  • 4
  • 15
  • 39
  • I think this would be simpler to answer if you were to [include code examples](https://stackoverflow.com/help/minimal-reproducible-example) so potential answerers can understand or reproduce the problem. – arnt Oct 18 '19 at 12:36
  • 1
    Why do you allow different CLang versions if they behave differently? (In commercial projects often the tools and their versions have to be fixed to fulfill the requirements of software quality assurance or certifications.) – Bodo Oct 18 '19 at 13:35
  • Have you tried not using any v10 featrures, as they will be obviously unsupported by v9, and then specifying _every_single_one_ of the values, to avoid differences between defaults? Also, as @Bodo said, just stick to using one version across everything. – DeducibleSteak Jan 15 '20 at 15:58
  • 2
    @Bodo for starters, there's quite a difference between the compiler toolchain and auxiliary tools. In this case `clang-format` has _some_ connection to _a_ compiler toolchain, but can be and is often used as a standalone tool (e.g. while still using MSVC and/or GCC to build binaries). Just like `.editorconfig` should yield the same behavior across editors/IDEs of various versions, that would also be my expectation of `.clang-format`. I can understand that the Clang folks do not want to carry backward compatibility around (their codebase doesn't for the most part), but it's still annoying. – 0xC0000022L Jun 15 '20 at 14:57

1 Answers1

0

Just in order to close the thread: it looks like you cant. Just enforce clang tools version check through build system.

Roman
  • 1,396
  • 4
  • 15
  • 39