chad_standard/README.md
2023-12-11 17:19:23 +00:00

2.8 KiB

Coding Standard

Compialation

  • remove all warnings clang -Weverything gcc -Wall -Wextra -Wpedantic valgrind --show-leak-kinds=all --leak-check=full
  • under all cicumstances have (atleast a wrapper) Makefile for frenliness
  • GNU Make ok, that other Make with a prefix shall burn in hell
  • NOTE: (to Xolatile in particular) fuck splint

Multi-line comments

  • single line for separating logical blocks inside the same block
  • multiline for exaplaining code /* stuff * and more */
  • use them very sparsely

Headers

  • never use relative paths, manipulate the compiler
  • use #define type header guards
  • header guards shall be all caps _
  • make function forward declarations explicitly extern

Macros

  • only with consensus can any new macro be added to the codebase
  • always parenthesize values

Identaion

  • tabs
  • max 4 levels

Parenthesizing

  • do not parenthesize return statements
  • always add spacing around when after a control statement { if (condition) {...} }
  • do not pad the insides { (stuff) ; and not: ( stuff ) }
  • do not pad after function context { myfun(); }
  • always use to avoid relying on operator precedence { (a * b) + c }

Declarations

  • pointer '*'s always to the middle { char * s; }
  • dont concat pointer '*'s { char \* \* s; }
  • function heads belong on the same line
  • [static|extern] [inline] [type]
  • align adjecent ones horizontally
  • always typedef structs or make them anonymous

If

  • align logical operators under the keyword if if (a && b && c) {}
  • align negating operators and the lack of there of if (!a && b && !c) {}
  • always omit useless comperasions if (a) // good if (a != 0) // bad

Switch

switch(...) {
    case ...: {
    } beak;
}
  • GNU range extensions allowed

Loops

  • declare the iterator inside the loop
  • variables to use for iteration 'i' -> 'j' -> 'k'
  • use "while(1)" for infinit loops
  • no coma in condition unless its an assignment
  • never ommit brackets at empyt loop bodies

Operators

  • prefer prefix crementors when possible { ++i; }
  • use spaces (if you dont intuetively know what this means, kys)

Naming

  • namer chooses spelling, consistency must follow
  • snake_case
  • *_t on all typedefs
  • LOCAL variables shall be short enough to not use snake_case

Misc

  • keep a line width of 80
  • string null termination is spelled '\0'

Development Process

How to manage a group project

  1. Select PM
  2. Settle on the exact features
  3. Settle on the technologies
  4. Settle on basic structure
  5. Let the PM type out the frame with function prototypes / empty bodies
  6. Let the PM distribute the work
  7. Type away furiously