Search code examples
c++clangclang-format

.clang-format file for editing of c++ code: is clang version relevant?


I have a .clang-format file in my source directory for c++ code editing.

The file has entries like

AccessModifierOffset: -2

AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true

I already saw such a file in bigger libraries coming with a header

#
# The clang-format (Clang 11) style file used by our library 
#

My question is if a .clang-format file is bound to a specific version of clang? In other words, does it matter whether I have clang-6 or clang-16 installed or is the file generic for all clang versions?


Solution

  • Yes, the different clang-format versions may have different format result. We already met that issue in our project.