- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Creating a C/C++ Code Formatting tool with help of Clang tools
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!
Advertisements