Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

.clang_format

Maksim Shabunin edited this pageApr 2, 2024 ·8 revisions

Instruction

Note: clang-format 12 is used as a baseline

Installation

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

Debian/Ubuntu

sudo apt install clang-format

Ubuntu 22.04 - clang-format 14

Windows

One of variants:

OSX

brew install clang-format

Run

  • 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

Links

Future improvements

  • Create list of tracked files
  • Add cmake targets for check/format modes
  • Add CI task to check tracked files (in Documentation builder, for example)

Configuration

# 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

Clone this wiki locally


[8]ページ先頭

©2009-2025 Movatter.jp