Description: In the RTT to submit code, need to comply with RT-Thread code specifications, paper briefly describes how to use the code style format Astyle RTT meet the requirements.
About Astyle
Astyle stands Artistic Style short, is an open source source code formatting tools can be for C, C ++, C # and Java programming languages such as source code indentation, formatting, beautification.
Home Page: http://astyle.sourceforge.net/
Project Page: http://sourceforge.net/projects/astyle/
In Keil μVision integrated Astyle (with Keil μVison5 for example)
① download Astyle, unzip to any location (Astyle green software)
download link:
Link: https: //pan.baidu.com/s/1cGh2yA7T0F22hpVulz60GQ
Extraction code: m4hh
②μVision5, click the Tools menu --- Customize Tools Menu
③ add Astyle All Files and Astyle Current File menu (custom menu name, you can use Chinese)
Here adds two menus, which are all formatted file and the current file format in the project.
④ Add Command command: Click the ... button to select Astyle.exe in the installation directory Astyle in.
⑤Arguments:
Astyle Current File menu to fill -n E --style = allman --indent = spaces = 4 --indent-preproc-block --pad-oper --pad-header --unpad-paren --suffix = none! - align-pointer = name --lineend = linux --convert-tabs --verbose current file
Astyle All Files菜单填写 -n "$E*.c" "$E*.h" --style=allman --indent=spaces=4 --indent-preproc-block --pad-oper --pad-header --unpad-paren --suffix=none --align-pointer=name --lineend=linux --convert-tabs --verbose
All current .c and .h files in the folder where the file
Note:! E indicates the file is currently being edited and has focus.
$ E * .c and $ E * .h on behalf of the currently focused and editing files in the directory where all .c and .h files (refer keil uVision help documentation)
Astyle default format is used to format documents, while you can also customize the format, custom format reference Astyle help documentation. After the default format, the original file is backed up .orig for the source file name. If you do not want Astyle backup files, you can use the -n parameter. Such as:! -N E (represents the current file format, not the backup)
⑥ actual results are as follows:
After using formatting commands:
It has finished:
NOTE: RTT parameters Brief Description: See Specific D: GEN_FILE_000005_V1.0% 20AStyle_3.1_windows \ AStyle \ doc described
With automatic formatting code astyle
This style --style = allman braces use a separate line
--indent = spaces = 4 indented four spaces
--indent-preproc-block by block pretreated
--pad-oper add a space before and after the operator
--pad-header is inserted into a space behind the like if for while
--unpad-paren remove extra spaces inside the brackets
--suffix = none does not require a backup that is -n
--align-pointer = name *, &, or ^ placed next variable name
--lineend = linux line end style Valid options are windows (CRLF), linux (LF), and macold (CR).
--convert-tabs to spaces when converting the tab indent
--verbose detailed display mode
* Blog content for the users personal publishing, bloggers represent only personal views, if infringement please contact the staff deleted.