diff options
| -rw-r--r-- | handbook/codestyle | 57 | ||||
| -rw-r--r-- | handbook/handbook (renamed from HANDBOOK) | 4 |
2 files changed, 57 insertions, 4 deletions
diff --git a/handbook/codestyle b/handbook/codestyle new file mode 100644 index 0000000..38237e1 --- /dev/null +++ b/handbook/codestyle @@ -0,0 +1,57 @@ +~~~ Code style ~~~ +- based on K&R conventions +- line length: 80 characters +- comments: /* like this */ + + +%%% If statements +if (var <= 64) { + return TRUE; +} else if (var - vor >= 64 && + var + vor <= 128) { + return TRUE; +} else { + return FALSE; +} + + +%%% Switch statement +/* between case blocks could be one empty line if they are enough big */ +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 + +typedef struct foobar_struct { + 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 */ diff --git a/HANDBOOK b/handbook/handbook index 3b36132..b60f2ea 100644 --- a/HANDBOOK +++ b/handbook/handbook @@ -28,10 +28,6 @@ - keep them clear and following standard scheme - if a filename is to be mentioned, don't use any quotes and try to situate it to the end of the string -* Code style -- you can use kr.sh script for basic orientation, but think with your head and correct all bull shits -- at the end of each file leave one empty line - * Writing a module * Creating a package |