clang-format 样式文件路径格式不起作用

问题描述 投票:0回答:1

我正在使用

clang-format
15。根据文档,可以使用
--style
使用
--style='file:<format_file_path>
选项指定自定义样式文件。

但是,我在实际路径规范方面遇到问题,不会产生

Invalid value for -style
错误。如果格式文件像这样是本地的,那么一切都很好:

clang-format --dry-run --fcolor-diagnostics --verbose --style='file:cmt.txt' -Werror ./template.h

但是如果它位于其他地方,则没有任何作用。我已经尝试过这些可能性:

clang-format --dry-run --fcolor-diagnostics --verbose --style='file:/cmt.txt' -Werror ./template.h
clang-format --dry-run --fcolor-diagnostics --verbose --style="file:/cmt.txt" -Werror ./template.h
clang-format --dry-run --fcolor-diagnostics --verbose --style=file://cmt.txt -Werror ./template.h
clang-format --dry-run --fcolor-diagnostics --verbose --style=file:\/cmt.txt -Werror ./template.h

是否有

clang-format
可以接受的特殊字符组合? 我在 msys2 中使用 bash 5.2.15。

bash msys2 clang-format
1个回答
0
投票

我在使用绝对路径时遇到了同样的问题,发现这不起作用

clang-format --style=file:/c/.clang-format -n /c/src/main.c

但是以下有效

clang-format --style=file:c:\.clang-format -n c:\src\main.c

在您的情况下,正确的命令应该如下:

clang-format --dry-run --fcolor-diagnostics --verbose --style="file:../cmt.txt" -Werror ./template.h
© www.soinside.com 2019 - 2024. All rights reserved.