source: libcaca/trunk/doc/style.dox @ 3266

Last change on this file since 3266 was 1879, checked in by Sam Hocevar, 12 years ago
  • Renamed doxygen sections here and there to avoid embarassing side-effects such as "man tutorial" showing the libcaca tutorial on Debian systems.
  • Property svn:keywords set to Id
File size: 1.9 KB
Line 
1/* $Id: style.dox 1879 2007-11-04 11:59:54Z sam $ */
2
3/** \page libcaca-style Libcaca coding style
4
5 \section sty1 General guidelines
6
7 A pretty safe rule of thumb is: look at what has already been done and
8 try to do the same.
9
10 - Tabulations should be avoided and replaced with \e eight spaces.
11 - Indentation is generally 4 spaces.
12 - Lines should wrap at most at 79 characters.
13 - Do not leave whitespace at the end of lines.
14 - Do not use multiple spaces for anything else than indentation.
15 - Code qui fait des warnings == code de porc == deux baffes dans ta gueule
16
17 \section sty2 C coding style
18
19 Try to use short names whenever possible (\c i for indices, \c w for width,
20 \c cv for canvas...). Macros are always uppercase, variable and function
21 names are always lowercase. Use the underscore to separate words within
22 names:
23
24 \code
25#define BROKEN 0
26#define MAX(x, y) ((x > y) ? (x) : (y))
27
28unsigned int x, y, w, h;
29char *font_name;
30void frobulate_every_three_seconds(void);
31 \endcode
32
33 \c const is a \e suffix. It's \c char \c const \c *foo, not \c const \c char
34 \c *foo.
35
36 Use spaces after commas and between operators. Do not use spaces after an
37 opening parenthesis or before a closing one:
38
39 \code
40a += 2;
41b = (a * (c + d));
42x = min(x1, x2, x3);
43 \endcode
44
45 Do not put a space between functions and the corresponding opening
46 parenthesis:
47
48 \code
49int function(int);
50
51if(a == b)
52    return;
53 \endcode
54
55 Do not put parentheses around return values:
56
57 \code
58return a + (b & x) + d[10];
59 \endcode
60
61 Opening braces should be on a line of their own, aligned with the
62 current block. Braces are optional for one-liners:
63
64 \code
65int function(int a)
66{
67    if(a & 0x84)
68        return a;
69
70    if(a < 0)
71    {
72        return -a;
73    }
74    else
75    {
76        a /= 2;
77
78        switch(a)
79        {
80            case 0:
81            case 1:
82                return -1;
83                break;
84            default:
85                return a;
86        }
87    }
88}
89 \endcode
90
91 \section sty3 C++ coding style
92
93 Nothing here yet.
94
95*/
Note: See TracBrowser for help on using the repository browser.