| 1 |
INDENTATION |
| 2 |
Concordance currently uses 4-space indentation. |
| 3 |
|
| 4 |
|
| 5 |
PAGE-WIDTH |
| 6 |
Page-width should not be wider than 80 characters. If they are, you've nested |
| 7 |
your functions too deep and you need to re-factor your code. There are |
| 8 |
occasional execptions to this where something like a static_cast of a variable |
| 9 |
with a long name to a type with a long name may cause one line to be too long |
| 10 |
while everything else is fine. But this should be the exception, not the rule. |
| 11 |
|
| 12 |
|
| 13 |
SPACING |
| 14 |
We follow the K&R coding style. You should familiarize yourself with it. |
| 15 |
Additional specifics follow. |
| 16 |
|
| 17 |
Spaces are important. All operators should be surrounded by a space on either |
| 18 |
side, such as "i == 2" instead of "i==2". |
| 19 |
|
| 20 |
Parynthesis and brackets do not need spaces inside them. In otherwords you |
| 21 |
should have: |
| 22 |
if (i == 2) { |
| 23 |
|
| 24 |
and not: |
| 25 |
if ( i == 2 ) { |
| 26 |
|
| 27 |
The same thing for i[2] as opposed to i[ 2 ]. |
| 28 |
|
| 29 |
|
| 30 |
INDENTATION |
| 31 |
When breaking lines that are arguments to a function or parameters to a |
| 32 |
definition, align the second row with the columb the first row began at: |
| 33 |
|
| 34 |
some_function(one, two, three, four, five, six, seven, eight, nine, ten, |
| 35 |
eleven, twelve); |
| 36 |
|
| 37 |
If your function call is nested or very long and you'd rather not do that, you |
| 38 |
must start the first argument on it's own line like so: |
| 39 |
|
| 40 |
some_function( |
| 41 |
one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, |
| 42 |
thirteen); |
| 43 |
|
| 44 |
|
| 45 |
BRACKETS |
| 46 |
Do not use brackets around single-line if-statements unless it would be very |
| 47 |
unclear without them. In otherwords, do this: |
| 48 |
|
| 49 |
if (condition) |
| 50 |
thing(); |
| 51 |
|
| 52 |
and not: |
| 53 |
|
| 54 |
if (condition) { |
| 55 |
thing(); |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
CROSS-PLATFORM NOTES |
| 60 |
Code MUST be portable and cross-platform. Our codebase works on Linux, Mac OS |
| 61 |
X, BSD, Windows, and possibly others. As such it is important ensure any |
| 62 |
patches are cross-platform. |
| 63 |
|
| 64 |
Contributors are not expected to be familiar with all supported platforms, but |
| 65 |
should be willing to modify and re-submit patches in response to feedback from |
| 66 |
developers and other contributors regarding cross-platform issues. |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
# for vim to text-wrap |
| 73 |
vim:textwidth=78: |
| 74 |
|