clang-format 12 (12.0.1) 的选项是什么,它在 R 前缀和原始字符串之间放置一个空格:
std::string str = R"(raw string)";
Run Code Online (Sandbox Code Playgroud)
与
std::string str = R "(raw string)";
Run Code Online (Sandbox Code Playgroud)
gcc (9.3.0) 或 VSCode 1.62.3 使用的 clang 不接受后者,因此这实际上破坏了源文件/构建。
我的 .clang-format 文件设置会导致出现空格,内置的 gnu 预设也会出现这种情况。其他预设(llvm、google、chromium、microsoft、mozilla 或 webkit)都不会导致此问题。
我已经转储了所有格式,并逐个设置地比较了它们。我首先删除了配置中与未导致此问题的预设之一相匹配的所有设置。然后我消除了 gnu 预设和未添加空格的预设之间相同的任何剩余设置。最后,我检查了剩下的几个设置,并将 .clang-format 文件中的设置更改为工作预设中的值,以查看它们是否解决了问题,但它们没有。
这样做,我似乎已经消除了所有的设置作为原因。
在我花更多时间、几个小时挖掘实际的源代码之前,我希望有人对此有一些见解,并能够向我指出导致问题的设置。
作为参考,我在下面包含了我的 .clang-format 设置文件。但正如所指出的,gnu 预设也表现出这种行为。
谢谢你的帮助。
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignConsecutiveMacros: None
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: true
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: …Run Code Online (Sandbox Code Playgroud)