UE4 代码规范记录

目录

UE4源码工程的代码规范使用的是EditorConfig。

Clang-format使用


UE4源码工程的代码规范使用的是EditorConfig。

官方网址:EditorConfig

好处是:VS默认支持EditorConfig,不用下载插件。

示例文件:.editorconfig

# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# Baseline
[*]
charset = utf-8
indent_style = tab
indent_size = 4
tab_width = 4
trim_trailing_whitespace = false
max_line_length = 120

# MSBuild
[*.{csproj,proj,projitems,shproj,fsproj,target,props}]
indent_style = space
indent_size = 2

# XML config files
[*.{config,nuspec,resx,natvis}]
indent_style = space
indent_size = 2

# Python files
[*.py]
indent_style = space
indent_size = 4

Clang-format使用

1. 从 LLVM Download Page 下载安装文件。

  •  注意提前沟通好团队使用的版本。
  • 安装是勾选 add Path

2. 在VS上进行设置。Tools->Options

 3. 配置文件放在工程目录下。(.clang-format)

  • ---
    Language:        Cpp
    BasedOnStyle:  LLVM
    IndentWidth:     4
    UseTab:          Never
    Standard:        Cpp11
    BreakBeforeBraces: Allman
    PointerAlignment: Left
    AccessModifierOffset: -4
    AllowShortFunctionsOnASingleLine: None
    ColumnLimit: 80
    CompactNamespaces: false
    SortIncludes: false
    FixNamespaceComments: true
    SpacesBeforeTrailingComments: 1
    SpaceBeforeParens: ControlStatements
    SpaceBeforeRangeBasedForLoopColon: true
    SpaceBeforeCpp11BracedList: false
    SpaceBeforeCtorInitializerColon: false
    SpaceBeforeInheritanceColon: true
    BinPackParameters: false
    ...

  •  参考文档: Clang-Format Style Options — Clang 13 documentation

 4. 格式方式:Edit->Advanced-> 

  • Format Document (Shift+Alt+F)
  • Format Selection (Ctrl+D,Ctrl+F)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值