File: CodingStyle

package info (click to toggle)
concordance 1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,700 kB
  • sloc: cpp: 7,203; sh: 4,621; ansic: 882; python: 707; perl: 171; makefile: 132; xml: 34
file content (74 lines) | stat: -rw-r--r-- 2,076 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
INDENTATION
Concordance currently uses 4-space indentation.


PAGE-WIDTH
Page-width should not be wider than 80 characters. If they are, you've nested
your functions too deep and you need to re-factor your code. There are
occasional execptions to this where something like a static_cast of a variable
with a long name to a type with a long name may cause one line to be too long
while everything else is fine. But this should be the exception, not the rule.


SPACING
We follow the K&R coding style. You should familiarize yourself with it.
Additional specifics follow.

Spaces are important. All operators should be surrounded by a space on either
side, such as "i == 2" instead of "i==2".

Parynthesis and brackets do not need spaces inside them. In otherwords you
should have:
   if (i == 2) {

and not:
   if ( i == 2 ) {

The same thing for i[2] as opposed to i[ 2 ].


INDENTATION
When breaking lines that are arguments to a function or parameters to a
definition, align the second row with the columb the first row began at:

  some_function(one, two, three, four, five, six, seven, eight, nine, ten,
                eleven, twelve);

If your function call is nested or very long and you'd rather not do that, you
must start the first argument on it's own line like so:

  some_function(
    one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve,
    thirteen);


BRACKETS
Do not use brackets around single-line if-statements unless it would be very
unclear without them. In otherwords, do this:

  if (condition)
    thing();

and not:

  if (condition) {
    thing();
  }


CROSS-PLATFORM NOTES
Code MUST be portable and cross-platform. Our codebase works on Linux, Mac OS
X, BSD, Windows, and possibly others. As such it is important ensure any
patches are cross-platform.

Contributors are not expected to be familiar with all supported platforms, but
should be willing to modify and re-submit patches in response to feedback from
developers and other contributors regarding cross-platform issues.





# for vim to text-wrap
vim:textwidth=78: