Home >Backend Development >C++ >Create a C/C++ code formatting tool using Clang tool
In this tutorial, we will be discussing a program to create a C/C code formatting tool with the help of clang tools.
sudo apt install python sudo apt install clang-format-3.5
We will then create a Python file in a location where the current user has read and write permissions.
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)
Creates a file format file in the current user's top-level directory.
clang-format-3.5 -style=google -dump-config > .clang-format
Finally copy this file to the top-level directory of the current project.
Now you can use your own code formatting tool. Just run the created Python file and you're ready to go!
The above is the detailed content of Create a C/C++ code formatting tool using Clang tool. For more information, please follow other related articles on the PHP Chinese website!