微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

c – 具有多行函数声明参数的Clang格式问题

Clang格式一直这样做:
bool importSomethingIn( const boost::property_tree::ptree& inBoostTree,int inSomeIndex,std::shared_ptr<Something>
                            inSomething,int x,int y );

当我想要这样做:

bool importSomethingIn( const boost::property_tree::ptree& inBoostTree,std::shared_ptr<Something> inSomething,int y );

请注意,它是在符号之前添加一个换行符和缩进.它似乎始终是导致此行为的模板类型.

如何阻止这样做?

这是我当前的.clang格式:

BasedOnStyle: LLVM
Language: Cpp
AccessModifierOffset: -4
AlignescapednewlinesLeft: false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDeFinitionReturnType: true
AlwaysBreakBeforeMultilinestrings: false
AlwaysBreakTemplateDeclarations: false
BinPackParameters: false
BreakBeforeBinaryOperators: false
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
ColumnLimit: 120
CommentPragmas: ''
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointeralignment: false
DerivePointerBinding: false
ExperimentalAutoDetectBinPacking: false
IndentCaseLabels: true
IndentFunctionDeclarationAfterType: true
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000
PenaltyReturnTypeOnItsOwnLine: 60
Pointeralignment: Left
PointerBindsToType: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: true
Standard: Cpp11
TabWidth: 8
UseTab: Never

编辑:我使用cl格式Xcode插件,我获得了here在github 2016年7月(首先安装了阿尔卡特拉德然后ang格式插件与Aclatraz).我不完全确定clang格式二进制文件的位置,因此没有看到插件附带的版本号.

但是,根据下面的建议,我使用Homebrew安装了clang格式,它给了我3.9.0版本.然后我将Xcode插件设置为“使用系统clang-format”,并得到所需的结果,所以我猜这是一个bug.

解决方法

在ubuntu 16.04上,您的情况似乎很好,cl格式3.8

>安装clang-format-3.8

sudo apt-get install clang-format-3.8

>在〜/ .vimrc

map <F3> :pyf /usr/share/vim/addons/Syntax/clang-format-3.8.py<cr>                  
imap <F3> <C-o>:pyf /usr/share/vim/addons/Syntax/clang-format-3.8.py<cr>

>使用@ OP的.clang格式和源代码

mkdir ~/test
vim ~/test/.clang-format
vim ~/test/test.cpp

>在vim中格式化test.cpp(使用F3),然后结果:

bool importSomethingIn( const boost::property_tree::ptree& inBoostTree,int y );

原文地址:https://www.jb51.cc/c/113434.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐