67
Comment:
|
2065
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
## page was renamed from CodingConventions | |
Line 5: | Line 6: |
In progress... | We use {{{uncrustify}}} with a Fast Downward configuration file to enforce some of the formatting conventions. This page clarifies things that are not covered by {{{uncrustify}}} and/or unclear. == Breaking long lines == Preferably keep lines to 72 characters, or else to 80 characters. === Breaking function calls === Use one of these two ways to break function calls: 1. Break after opening parenthesis, indent following lines by four spaces. 2. Break after an argument, align after the opening parenthesis. The first way is usually preferred. {{{#!cplusplus int foobar1 = example_of_breaking_after_parenthesis( some_argument, foo + bar, baz, final_argument); int foobar2 = example_of_breaking_after_argument(some_argument, foo + bar, baz, final_argument); }}} === Breaking stream output === Break lines before {{{<<}}} or {{{>>}}} operators and align on these operators: {{{#!cplusplus cout << "here's a lot of introductory text to make this a long line; x = " << x << ", y = " << y << endl; }}} === Breaking function definition heads === 1. Prefer to keep everything on one line. 2. If this is too long, break as for function calls above. 3. If this is still too long, break after the return value type. {{{#!cplusplus void MyClass::everything_fits_on_one_line_here(double &x, int y) { // Case 1 above. } int *MyLongerClassName::ooh_it_does_not_really_fit_any_more_here( double &x, int y) { // Case 2 above. } int *MyLongerClassName::ooh_it_does_not_really_fit_any_more_here(double &x, int y) { // Case 2 above, variant. } MyEvenQuiteAFewWordsLongerClassName::NestedClassWithALongName * MyEvenQuiteAFewWordsLongerClassName::create_nested_class_with_a_long_name_instance( double &x, int y) { // Case 3 above. } }}} |
Back to the HomePage.
Coding conventions
We use uncrustify with a Fast Downward configuration file to enforce some of the formatting conventions. This page clarifies things that are not covered by uncrustify and/or unclear.
Breaking long lines
Preferably keep lines to 72 characters, or else to 80 characters.
Breaking function calls
Use one of these two ways to break function calls:
- Break after opening parenthesis, indent following lines by four spaces.
- Break after an argument, align after the opening parenthesis.
The first way is usually preferred.
Breaking stream output
Break lines before << or >> operators and align on these operators:
Breaking function definition heads
- Prefer to keep everything on one line.
- If this is too long, break as for function calls above.
- If this is still too long, break after the return value type.
1 void MyClass::everything_fits_on_one_line_here(double &x, int y) {
2 // Case 1 above.
3 }
4
5 int *MyLongerClassName::ooh_it_does_not_really_fit_any_more_here(
6 double &x, int y) {
7 // Case 2 above.
8 }
9
10 int *MyLongerClassName::ooh_it_does_not_really_fit_any_more_here(double &x,
11 int y) {
12 // Case 2 above, variant.
13 }
14
15 MyEvenQuiteAFewWordsLongerClassName::NestedClassWithALongName *
16 MyEvenQuiteAFewWordsLongerClassName::create_nested_class_with_a_long_name_instance(
17 double &x, int y) {
18 // Case 3 above.
19 }