Suppose there is a project folder D:\project\sourceclean_prj\sourcefolder and the output folder is D:\project\sourceclean_prj\output.
Recompile the project by adding compile options -save-temps=obj -fdirectives-only.
Here are steps to clean source code of the project.
1. Select input folder: Fill in an existing folder path.
2. Select input folder: You can also select a folder through the right "..." button.
3. Select ouput folder: Fill in an existing folder path or select/create a folder through the right "..." button.
4. Select Output file format.
5. Select Input and output file extensions. Set Input file extension as *.i and Output file extension as *.c
Input file extension | Input file format, usually *.i or *.ii |
Output file extension | Output file format, usually *.c or *.cpp. If Input file extension is same as output, then input files will be just copied into output folder. |
6. Click Source Clean button to start or stop the code cleaning process. The button caption will change to Stop during processing.
7. As shown below, it can be seen that each *.i file is processed into *.c file.
8. Re-select input folder. Re-select Input and output file extensions. Set Input file extension as *.h and Output file extension as *.h .
9. As shown below, it can be seen that each *.h file is copied as *.h file. Finally, in the output folder, there will be *.c and *.h, and the directory structure will be the same as that of the original project.
10. The following shows the difference between the source code before and after processing. Left side is the original source code in the project. Right side is the processed file. It can be seen that #ifdef #ifndef have been removed. The code generated after processing has become easy to read and understand.