C++ 如何在C++;?

C++ 如何在C++;?,c++,clang,clang-format,C++,Clang,Clang Format,我只是在学习使用铿锵格式。我主要是设法将其配置为符合我的口味,但我不知道如何使其缩进extern“C”块 这是理想的结果: extern "C" { void myFunction() { // ... } } 但我得到的是: extern "C" { void myFunction() { // ... } } 以下是我的配置: BasedOnStyle: 'LLVM' IndentWidth: 4 AccessModifierOffset: -4

我只是在学习使用铿锵格式。我主要是设法将其配置为符合我的口味,但我不知道如何使其缩进
extern“C”

这是理想的结果:

extern "C" {
    void myFunction() {
        // ...
    }
}
但我得到的是:

extern "C" {
void myFunction() {
    // ...
}
}
以下是我的配置:

BasedOnStyle: 'LLVM'
IndentWidth: 4
AccessModifierOffset: -4
AlignAfterOpenBracket: 'false'
AlignConsecutiveAssignments: 'false'
AlignConsecutiveDeclarations: 'false'
AlignEscapedNewlinesLeft: 'true'
AlignOperands: 'true'
AlignTrailingComments: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'true'
AllowShortBlocksOnASingleLine: 'false'
AllowShortCaseLabelsOnASingleLine: 'false'
AllowShortFunctionsOnASingleLine: 'true'
AllowShortIfStatementsOnASingleLine: 'false'
AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakAfterDefinitionReturnType: 'None'
AlwaysBreakAfterReturnType: 'None'
AlwaysBreakBeforeMultilineStrings: 'false'
AlwaysBreakTemplateDeclarations: 'true'
BinPackArguments: 'true'
BinPackParameters: 'true'
BreakBeforeBraces: 'Custom'
BreakBeforeTernaryOperators: false
BraceWrapping: {
  AfterClass: 'false'
  AfterControlStatement: 'false'
  AfterEnum: 'false'
  AfterFunction: 'false'
  AfterNamespace: 'false'
  AfterStruct: 'false'
  AfterUnion: 'false'
  BeforeCatch: 'true'
  BeforeElse: 'true'
  IndentBraces: 'false'
}
BreakConstructorInitializersBeforeComma: 'false'
BreakStringLiterals: 'false'
ColumnLimit: 0
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
DerivePointerAlignment: 'false'
KeepEmptyLinesAtTheStartOfBlocks: 'true'
MaxEmptyLinesToKeep: 1
NamespaceIndentation: 'All'
PointerAlignment: 'Right'
ReflowComments: 'false'
SortIncludes: 'false'
SpaceAfterCStyleCast: 'true'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeParens: 'ControlStatements'
SpaceInEmptyParentheses: 'false'
SpacesInAngles: 'false'
SpacesInCStyleCastParentheses: 'false'
SpacesInContainerLiterals: 'true'
SpacesInParentheses: 'false'
SpacesInSquareBrackets: 'false'
Standard: 'Cpp11'
TabWidth: 4
UseTab: 'Never'

clang格式的较新版本(我相信它是在LLVM 6中引入的)确实为BraceWrapping配置选项实现了AfterExternBlock标志。考虑将其设置为true。

< P>新版本CLAN格式(CLANG格式-10或更高版本)执行DuntExtButoButter标记

谢谢您的评论。我试过了。它工作得很好,但它也包装了
extern“C”
后面的大括号,我不想要它。有没有一种方法可以在不使用大括号的情况下缩进
外部“C”
的内容?我希望我知道:)我也在寻找这个。请编辑您的答案并添加源链接