In this tutorial, we will be discussing a program to create a C/C++ code formatting tool with the help of clang tools.
SETUP
sudo apt install python sudo apt install clang-format-3.5
Then we will create a python file in location where the current user has read and write permissions.
Example
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)
Create a file formatting file in the top directory of the current user.
Output
clang-format-3.5 -style=google -dump-config > .clang-format
Finally copy this file to the current projects top directory.
Now, you can use your own code formatting tool. Just run the created python and you are good to go!