Creating a C/C++ Code Formatting tool with help of Clang tools
Last Updated : 16 Jul, 2020
Today we are going to discuss formatting files in the user's workspace by their extension. For this we are going to make use of Clang's format tools.
Prerequisites:
Linux Machine
Python
Clang Tool
Setup:
Install Python using the following command:
sudo apt-get install python
Install Clang Format Tools
sudo apt-get install clang-format-3.5
Create a python file named format-code.py at any location where you have read and write permissions. In this example we are going to create it in /home/user/. It shall contain the following code:
Create format specification file and copy it to project's top level directory , e.g., /home/user/myproject/
Create formatting file (in example, we are creating google coding style tool)