zoukankan      html  css  js  c++  java
  • Astyle 格式化代码

    什么是Astyle

    A Free, Fast, and Small Automatic Formatter for C, C++, C++/CLI, Objective‑C, C#, and Java Source Code

    官网

    Command prompt

    保存成astyle-format.bat放在文件目录即可.

    REM File Name: astyle-format.bat
    
    astyle                  ^
    *.c                     ^
    *.cpp                   ^
    *.h                     ^
    --add-braces            ^
    --align-method-colon    ^
    --align-pointer=name    ^
    --align-reference=name  ^
    --attach-closing-while  ^
    --break-blocks          ^
    --break-elseifs         ^
    --convert-tabs          ^
    --delete-empty-lines    ^
    --indent-col1-comments  ^
    --indent-continuation=4 ^
    --indent-labels         ^
    --indent-namespaces     ^
    --indent-preproc-block  ^
    --indent-preproc-define ^
    --indent-switches       ^
    --indent=spaces=4       ^
    --pad-comma             ^
    --pad-header            ^
    --pad-oper              ^
    --recursive             ^
    --style=java            ^
    --unpad-paren
    

    注意

    • 文件名不能astyle.cmd 或者 astyle.bat 因为上面代码中的astyle会变成执行astyle.cmd或者astyle.bat文件, 会导致死循环
    • 当没有*.c/*.cpp/*.h三者只要有一个文件类型不存在, 命令将不会运行, 你可以手动去掉不存在的文件类型
      我是怎么知道的? 打开命令行再输入astyle-format.bat会报错:

    Directory C:UsersPCDesktopprojectpharmacy store management*.c
    No file to process *.c
    Artistic Style has terminated

  • 相关阅读:
    数据结构-链式结构-队列
    c数据结构-线性结构-队列
    栈的四则运算的运用
    C++/C—函数指针
    向显存写数据x8086
    结构体内存偏移量
    MFC-ComboBox控件的使用
    MFC的Edit text编辑框控件
    C/C++反汇编-各种表达式(加减乘)
    MFC- 学习控件-静态文本
  • 原文地址:https://www.cnblogs.com/codworm/p/12430427.html
Copyright © 2011-2022 走看看