Unify output with different clang-format versions
Asked Answered
L

1

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?

Laminitis answered 18/10, 2019 at 12:25 Comment(4)
I think this would be simpler to answer if you were to include code examples so potential answerers can understand or reproduce the problem.Aarhus
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.)Furniture
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 @Furniture said, just stick to using one version across everything.Deckle
@Furniture 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.Effeminate
L
0

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

Laminitis answered 27/7, 2023 at 21:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.