在Clang工具的帮助下创建C / C ++代码格式化工具
在本教程中,我们将讨论在clang工具的帮助下创建C/C++代码格式化工具的程序。
建立
sudo apt install python sudo apt install clang-format-3.5
然后,我们将在当前用户具有读写权限的位置创建一个python文件。
示例
import os
cpp_extensions = (".cxx",".cpp",".c", ".hxx", ".hh", ".cc", ".hpp")
for root, dirs, files in os.walk(os.getcwd()):
for file in files:
if file.endswith(cpp_extensions):
os.system("clang-format-3.5 -i -style=file " + root + "/" + file)在当前用户的顶层目录中创建文件格式文件。
输出结果
clang-format-3.5 -style=google -dump-config > .clang-format
最后将此文件复制到当前项目的顶层目录。
现在,您可以使用自己的代码格式化工具。只需运行创建的python,就可以了!
热门推荐
6 送蛇的祝福语简短
10 年月日祝福语简短
11 娃娃考试祝福语幽默简短
12 发廊元旦祝福语大全简短
13 幼儿狗年祝福语大全简短
14 妹妹生日祝福语简短唯美
15 十月简短祝福语
16 爱情贺卡祝福语简短英语
17 写给老师祝福语简短大学
18 祝福语大全简短6个