如何在一行中禁用自动组CODO以获取短函数


int compare (const void * a, const void * b) {
  return ( *(int*)a - *(int*)b );
}

以下命令将上述代码缩进。我想保留其原始样式(如果是一行,输出是一行,如果输入是三行,则输出应为三行。)是否可以使用clang-format

$ clang-format -style='{IndentWidth: 8, UseTab: Always, SpaceBeforeParens: Never, IndentCaseLabels: true }'
int compare(const void *a, const void *b) { return (*(int *)a - *(int *)b); }

给定 input.cpp

int compare (const void * a, const void * b) { return ( *(int*)a - *(int*)b ); }

这是使用AllowShortFunctionsOnASingleLine: None的结果:

% clang-format -style='{AllowShortFunctionsOnASingleLine: None}' input.cpp
int compare(const void *a, const void *b) {
  return (*(int *)a - *(int *)b);
}
% clang-format --version
7.0.1

最新更新