MaJerle / c-code-style

Recommended C code style and coding rules for standard C99 or later

Home Page:http://majerle.eu

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

May be we need a .clang-format

Logiase opened this issue · comments

Many IDE and editors use clang-format to format code, like VSCode, Clion, Visual Studio, QtCreator.

clang-format style docs: https://clang.llvm.org/docs/ClangFormatStyleOptions.html

BasedOnStyle: GNU may help

Many IDE and editors use clang-format to format code, like VSCode, Clion, Visual Studio, QtCreator.

clang-format style docs: https://clang.llvm.org/docs/ClangFormatStyleOptions.html

BasedOnStyle: GNU may help

Can you make a pull request?

---
Language: Cpp
BasedOnStyle: GNU
IndentWidth: 4
AllowShortBlocksOnASingleLine: Empty
AllowShortFunctionsOnASingleLine: None
BreakBeforeBraces: Custom
SpaceBeforeParens: ControlStatements
BraceWrapping:
  AfterFunction: false

This may help, just put it to your project root and rename to .clang-format, and format code, most editors will use it.

I use template.c and template.h, it works fine, but it need more tests.

I came up with this so far.

Do you know how to align macro definitions to certain column?

---
Language: Cpp
BasedOnStyle: GNU
IndentWidth: 4
AllowShortBlocksOnASingleLine: Empty
AllowShortFunctionsOnASingleLine: None
SpaceBeforeParens: ControlStatements
BreakBeforeBraces: Custom
BraceWrapping:
  AfterFunction: false
  AfterCaseLabel: false
  AfterEnum: false
  AfterControlStatement: Never
  AfterStruct : false
  AfterUnion : false
  AfterExternBlock : false
  BeforeElse : false
  BeforeWhile : false
AlignAfterOpenBracket: Align
AlignArrayOfStructures: Left
AlignEscapedNewlines: Right
AlignOperands: Align
AllowShortBlocksOnASingleLine: Empty
AllowShortEnumsOnASingleLine: False
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine : false
AlwaysBreakAfterReturnType: AllDefinitions
AlignTrailingComments : true
AlignConsecutiveMacros: AcrossEmptyLines
InsertBraces : true
KeepEmptyLinesAtTheStartOfBlocks : false
PointerAlignment : Left
QualifierAlignment : Left
ReferenceAlignment : Left
RemoveBracesLLVM : false
SpaceAfterCStyleCast : false
SpaceAfterLogicalNot : false
SpaceAfterTemplateKeyword : false
SpaceAroundPointerQualifiers : Before
SpaceBeforeAssignmentOperators : true
SpaceBeforeCaseColon : false
SpaceBeforeCpp11BracedList : false
SpaceBeforeParens : ControlStatements
SpaceBeforeParensOptions :
  AfterControlStatements : true
  AfterFunctionDeclarationName : false
  AfterFunctionDefinitionName : false
  AfterOverloadedOperator : false
SpaceBeforeRangeBasedForLoopColon : false
SpaceBeforeSquareBrackets : false
SpaceInEmptyBlock : false
SpaceInEmptyParentheses : false
SpacesInCStyleCastParentheses : false
SpacesInConditionalStatement : false
SpacesInContainerLiterals : false
SpacesInParentheses: false
SpacesInSquareBrackets : false
UseTab : Never

BitFieldColonSpacing: None
BreakBeforeBinaryOperators: true

if it helps, ive also found this site when i was testing for clang-format configurations:

https://zed0.co.uk/clang-format-configurator/
source: https://github.com/zed0/clang-format-configurator