Commit c012af40 authored by xHire's avatar xHire
Browse files

Base skeletons of codestyle and handbook

WIP
parent d6bf1192
~~~ Code style ~~~
- based on K&R conventions
- line length: 80 characters
- comments: /* like this */
%%% If statements
if (var <= 64) {
return 0;
} else if (var - vor >= 64 && /* operators at the end of a line */
var + vor <= 128) {
return 0;
} else {
return 1;
}
%%% Switch statement
/* between case blocks could be one empty line if they are big enough */
switch (var) {
case 10:
return 3;
break;
case 20:
return 30;
break;
default:
return 0;
break;
}
%%% Header files
#ifndef FOO_H
#define FOO_H
#include <foolib.h>
#include "bar.h"
#define FOO 1
#define BAR 2
struct s_foo {
int foo;
};
typedef struct s_foobar {
int foo;
char *bar;
} foobar_t;
typedef struct {
int foo;
char *bar;
} barfoo_t;
/* breaking lines only when longer than 80 characters or for special purposes */
extern foobar_t *foo_new(int faa, int fae,
char *bor, char *ber);
#endif /* FOO_H */
~~~ Developers’ Handbook ~~~
* Basic rules
- always discuss your problem with other developers or with maintainer of the
appropriate section
- stick with the project style and don’t import your own habits
- be present on developer’s IRC
- be inclusive: discuss your development efforts with others, keep everyone in
the loop
* Git
- try to make clean commits (`git diff --staged` before commiting)
- break things into commits that make sense (`git add -p` to choose changes)
- push upstream only commits with changes you want to record forever in the
repository
- write descriptive commit messages
- use .git/info/exclude to ignore your personal stuff, .gitignore to ignore
general files that most people will have in their tree
* Filenames and identifiers
- keep letters small
- if you need more words in a name, use the underscore character (_)
- name them reasonably
- don’t use global variables unless *really* needed
- if you create new source files, copy the standard header comment in there
* Documentation
- always accompany your code with comments so that others can read it without
spending time on figuring out what it is meant to do
- document functions and structures with doxygen comments
* Open questions
- typedefs
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment