1libcaca-style(3caca)                libcaca               libcaca-style(3caca)
2
3
4

NAME

6       libcaca-style - Libcaca coding style
7

General guidelines

9       A pretty safe rule of thumb is: look at what has already been done and
10       try to do the same.
11
12       • Tabulations should be avoided and replaced with eight spaces.
13
14       • Indentation is generally 4 spaces.
15
16       • Lines should wrap at most at 79 characters.
17
18       • Do not leave whitespace at the end of lines.
19
20       • Do not use multiple spaces for anything else than indentation.
21
22       • Code qui fait des warnings == code de porc == deux baffes dans ta
23         gueule
24

C coding style

26       Try to use short names whenever possible (i for indices, w for width,
27       cv for canvas...). Macros are always uppercase, variable and function
28       names are always lowercase. Use the underscore to separate words within
29       names:
30
31       #define BROKEN 0
32       #define MAX(x, y) ((x > y) ? (x) : (y))
33
34       unsigned int x, y, w, h;
35       char *font_name;
36       void frobulate_every_three_seconds(void);
37
38       const is a suffix. It's char const *foo, not const char *foo.
39
40       Use spaces after commas and between operators. Do not use spaces after
41       an opening parenthesis or before a closing one:
42
43       a += 2;
44       b = (a * (c + d));
45       x = min(x1, x2, x3);
46
47       Do not put a space between functions and the corresponding opening
48       parenthesis:
49
50       int function(int);
51
52       A space can be inserted after keywords such as for, while or if, but
53       consistency with the rest of the page is encouraged:
54
55       if(a == b)
56           return;
57
58       if (p == NULL)
59
60       Do not put parentheses around return values:
61
62       return a + (b & x) + d[10];
63
64       Opening braces should be on a line of their own, aligned with the
65       current block. Braces are optional for one-liners:
66
67       int function(int a)
68       {
69           if(a & 0x84)
70               return a;
71
72           if(a < 0)
73           {
74               return -a;
75           }
76           else
77           {
78               a /= 2;
79
80               switch(a)
81               {
82                   case 0:
83                   case 1:
84                       return -1;
85                       break;
86                   default:
87                       return a;
88               }
89           }
90       }
91

C++ coding style

93       Nothing here yet.
94
95
96
97Version 0.99.beta20             Sun Sep 24 2023           libcaca-style(3caca)
Impressum