From: Daniel Carl Date: Tue, 18 Oct 2016 22:31:55 +0000 (+0200) Subject: More code style hints. X-Git-Url: https://git.owens.tech/rss.xml/rss.xml/git?a=commitdiff_plain;h=2e99f769fb75d81e251efe1e2f8bcfca410f16c9;p=vimb.git More code style hints. --- diff --git a/README.md b/README.md index e22640d..087a139 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,41 @@ If you like to have a working vimb, please use the master branch. ## Patching and Coding style +### File Layout + +- Comment with LICENSE and possibly short explanation of file/tool +- Headers +- Macros +- Types +- Function declarations + - Include variable names + - For short files these can be left out + - Group/order in logical manner +- Global variables +- Function definitions in same order as declarations +- main + +### C Features + +- Do not mix declarations and code +- Do not use for loop initial declarations +- Use `/* */` for comments, not `//` + +### Headers + +- Place system/libc headers first in alphabetical order + - If headers must be included in a specific order comment to explain +- Place local headers after an empty line + +### Variables + +- Global variables not used outside translation unit should be declared static +- In declaration of pointers the `*` is adjacent to variable name, not type + +### Indentation + - the code is indented by 4 spaces - if you use vim to code you can set `:set expandtab ts=4 sts=4 sw=4` -- the functions are sorted alphabetically within the c files - it's a good advice to orientate on the already available code - if you are using `indent`, following options describe best the code style - `--k-and-r-style`