Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork56.4k
.clang_format
Maksim Shabunin edited this pageApr 2, 2024 ·8 revisions
Note: clang-format 12 is used as a baseline
Standalone LLVM builds - LLVM GitHub Releases:https://github.com/llvm/llvm-project/releases
For example 16:https://github.com/llvm/llvm-project/releases/tag/llvmorg-16.0.4
sudo apt install clang-format
Ubuntu 22.04 - clang-format 14
One of variants:
- Visual studio component "C++ Clang Tools for Windows"
- Visual Studio extension:https://marketplace.visualstudio.com/items?itemName=LLVMExtensions.ClangFormat
brew install clang-format
- Run in "check" mode (print formatting issues)
clang-format --style=file:${HOME}/my-clang-format --dry-run --Werror <path-to-src-file> - Run in "inplace edit" mode (replace file contents with formatted code)
clang-format --style=file:${HOME}/my-clang-format -i <path-to-src-file> - Run in editor using extension: consult your editor/extension documentation
- (ver. 12) introduction + editor integrations:https://releases.llvm.org/12.0.0/tools/clang/docs/ClangFormat.html
- (ver. 12) configuration reference:https://releases.llvm.org/12.0.0/tools/clang/docs/ClangFormatStyleOptions.html
- (latest) Introduction:https://clang.llvm.org/docs/ClangFormat.html
- Create list of tracked files
- Add cmake targets for check/format modes
- Add CI task to check tracked files (in Documentation builder, for example)
# clang-format version 12# https://releases.llvm.org/12.0.0/tools/clang/docs/ClangFormatStyleOptions.htmlBasedOnStyle:LLVMAccessModifierOffset:-4AlignAfterOpenBracket:AlignAlignConsecutiveAssignments:NoneAlignConsecutiveBitFields:NoneAlignConsecutiveDeclarations:NoneAlignConsecutiveMacros:NoneAlignEscapedNewlines:DontAlignAlignOperands:AlignAlignTrailingComments:falseAllowAllArgumentsOnNextLine:falseAllowAllConstructorInitializersOnNextLine:falseAllowAllParametersOfDeclarationOnNextLine:falseAllowShortBlocksOnASingleLine:NeverAllowShortCaseLabelsOnASingleLine:trueAllowShortEnumsOnASingleLine:trueAllowShortFunctionsOnASingleLine:EmptyAllowShortIfStatementsOnASingleLine:NeverAllowShortLambdasOnASingleLine:NoneAllowShortLoopsOnASingleLine:falseAlwaysBreakAfterReturnType:NoneAlwaysBreakBeforeMultilineStrings:falseAlwaysBreakTemplateDeclarations:YesBinPackArguments:falseBinPackParameters:falseBitFieldColonSpacing:BothBreakBeforeBraces:CustomBraceWrapping:AfterCaseLabel:trueAfterClass:trueAfterControlStatement:AlwaysAfterEnum:trueAfterFunction:trueAfterNamespace:falseAfterObjCDeclaration:trueAfterStruct:trueAfterUnion:trueAfterExternBlock:trueBeforeCatch:trueBeforeElse:trueBeforeLambdaBody:falseBeforeWhile:trueIndentBraces:falseSplitEmptyFunction:trueSplitEmptyRecord:trueSplitEmptyNamespace:trueBreakBeforeBinaryOperators:NoneBreakBeforeTernaryOperators:trueBreakConstructorInitializers:AfterColonBreakInheritanceList:AfterColonBreakStringLiterals:trueColumnLimit:100CompactNamespaces:trueConstructorInitializerAllOnOneLineOrOnePerLine:falseContinuationIndentWidth:4Cpp11BracedListStyle:trueDerivePointerAlignment:falseFixNamespaceComments:trueIncludeBlocks:PreserveIndentCaseLabels:trueIndentExternBlock:NoIndentIndentPPDirectives:AfterHashIndentWidth:4IndentWrappedFunctionNames:trueInsertTrailingCommas:NoneKeepEmptyLinesAtTheStartOfBlocks:falseLanguage:CppMaxEmptyLinesToKeep:2NamespaceIndentation:NonePenaltyBreakBeforeFirstCallParameter:15PenaltyBreakString:10#PenaltyReturnTypeOnItsOwnLine: 15#PenaltyExcessCharacter: 3PenaltyIndentedWhitespace:1PointerAlignment:LeftReflowComments:trueSortIncludes:falseSortUsingDeclarations:falseSpaceAfterCStyleCast:falseSpaceAfterLogicalNot:falseSpaceAfterTemplateKeyword:trueSpaceBeforeAssignmentOperators:trueSpaceBeforeCaseColon:falseSpaceBeforeCpp11BracedList:trueSpaceBeforeCtorInitializerColon:trueSpaceBeforeInheritanceColon:trueSpaceBeforeParens:ControlStatementsExceptForEachMacrosSpaceBeforeRangeBasedForLoopColon:trueSpaceBeforeSquareBrackets:falseSpaceInEmptyBlock:falseSpaceInEmptyParentheses:falseSpacesBeforeTrailingComments:2SpacesInAngles:falseSpacesInCStyleCastParentheses:falseSpacesInConditionalStatement:falseSpacesInContainerLiterals:falseSpacesInParentheses:falseSpacesInSquareBrackets:falseStandard:c++11TabWidth:8UseTab:Never#WhitespaceSensitiveMacros: ["CV_Check"]
© Copyright 2019-2025, OpenCV team