Skip to content

Add a .clang-format file for C tools #1205

@Rangi42

Description

@Rangi42

We have a STYLE.md guide for .asm formatting (tab indentation, lowercase instructions, etc), although there isn't an automated tool for it (yet! "rgbfmt" has been proposed before).

We also have many C tools, which could benefit from easy consistent formatting. Our current formatting includes:

  • C11 standard
  • Tab indentation
  • "Java-style" brace/whitespace styling
  • Braces required around blocks
  • Variable declarations at first use (not all grouped at the function start)
  • cases indented the same level as their switch
  • Explicit // fallthrough comments for cases
  • et cetera; we're pretty good about keeping consistent rules, so a .clang-format file could be tweaked to match our current conventions as closely as possible
  • No strict line length limit yet, but only 29 lines out of more than 1,500 are above 100 characters, 11 are above 120, 6 are above 130; since many long lines are from long #define USAGE_OPTS strings, and function signatures with many args, I think 100 would be appropriate when a tool like clang-format can enforce it

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions