2015-11-05 13 views
13

私はC++コードをフォーマットするためにclang-formatを使用します。私は、クラス宣言とそのような周囲の名前空間の閉じ括弧の間に空白行がしたい:clang-format:クラス宣言の終わりと名前空間の終了の間の空行

namespace Foo { 

class Bar { 
}; 

} 

をしかし、打ち鳴らす形式はこれに私のコードを変更します。

namespace Foo { 

class Bar { 
}; 
} 

それは削除されますクラス宣言と名前空間の閉じ括弧の間の空行。

私の質問:空の行を削除するclang形式を防ぐ方法はありますか?

これは私の現在の打ち鳴らす形式の設定です:

Language: Cpp 
AccessModifierOffset: -4 
AlignAfterOpenBracket: true 
AlignConsecutiveAssignments: false 
AlignEscapedNewlinesLeft: false 
AlignOperands: false 
AlignTrailingComments: false 
AllowAllParametersOfDeclarationOnNextLine: true 
AllowShortBlocksOnASingleLine: false 
AllowShortCaseLabelsOnASingleLine: false 
AllowShortFunctionsOnASingleLine: false 
AllowShortIfStatementsOnASingleLine: false 
AllowShortLoopsOnASingleLine: false 
AlwaysBreakAfterDefinitionReturnType: None 
AlwaysBreakBeforeMultilineStrings: true 
AlwaysBreakTemplateDeclarations: true 
BinPackArguments: true 
BinPackParameters: true 
BreakBeforeBinaryOperators: None 
BreakBeforeBraces: Attach 
BreakBeforeTernaryOperators: false 
BreakConstructorInitializersBeforeComma: false 
ColumnLimit: 80 
CommentPragmas: '^ IWYU pragma:' 
ConstructorInitializerAllOnOneLineOrOnePerLine: true 
ConstructorInitializerIndentWidth: 0 
ContinuationIndentWidth: 4 
Cpp11BracedListStyle: true 
DerivePointerAlignment: true 
DisableFormat: false 
ExperimentalAutoDetectBinPacking: false 
ForEachMacros: [foreach, Q_FOREACH, BOOST_FOREACH] 
IndentCaseLabels: false 
IndentWidth: 4 
IndentWrappedFunctionNames: false 
KeepEmptyLinesAtTheStartOfBlocks: false 
MacroBlockBegin: '' 
MacroBlockEnd: '' 
MaxEmptyLinesToKeep: 1 
NamespaceIndentation: None 
ObjCBlockIndentWidth: 4 
ObjCSpaceAfterProperty: true 
ObjCSpaceBeforeProtocolList: true 
PenaltyBreakBeforeFirstCallParameter: 1 
PenaltyBreakComment: 300 
PenaltyBreakFirstLessLess: 120 
PenaltyBreakString: 1000 
PenaltyExcessCharacter: 1000000 
PenaltyReturnTypeOnItsOwnLine: 200 
PointerAlignment: Left 
SpaceAfterCStyleCast: false 
SpaceBeforeAssignmentOperators: true 
SpaceBeforeParens: ControlStatements 
SpaceInEmptyParentheses: false 
SpacesBeforeTrailingComments: 4 
SpacesInAngles: false 
SpacesInCStyleCastParentheses: false 
SpacesInContainerLiterals: false 
SpacesInParentheses: false 
SpacesInSquareBrackets: false 
Standard: Cpp11 
TabWidth: 4 
UseTab: Never 

答えて

9

私はこの問題を回避するための一つの方法が見つかりました:次のように、自分の名前空間の閉じ括弧にインラインコメントを追加するには:

namespace my_namespace { 

class MyClass { 
    int n; 
}; 

} // namespace my_namespace 
関連する問題