mirror of
https://github.com/cc65/cc65.git
synced 2024-12-24 11:31:31 +00:00
Update Contributing.md
This commit is contained in:
parent
ba5859f724
commit
75ee10478e
@ -48,16 +48,36 @@ color := $0787
|
|||||||
|
|
||||||
## C Sources
|
## C Sources
|
||||||
|
|
||||||
|
The following is still very incomplete - if in doubt please look at existing sourcefiles and adapt to the existing style
|
||||||
|
|
||||||
* Your files should obey the C89 standard.
|
* Your files should obey the C89 standard.
|
||||||
|
* The normal indentation width should be four spaces.
|
||||||
|
* You must use ANSI C comments (```/* */```); you must not use C++ comments (```//```).
|
||||||
|
* When you add functions to an existing file, you should separate them by the same number of blank lines that separate the functions that already are in that file.
|
||||||
|
* All function declarations must be followed by a comment block that tells at least briefly what the function does, what the parameters are, and what is returned. This comment must sit between the declaration and the function body, like this:
|
||||||
|
<pre>
|
||||||
|
int foo(int bar)
|
||||||
|
/* Add 1 to bar, takes bar and returns the result */
|
||||||
|
{
|
||||||
|
return bar + 1;
|
||||||
|
}
|
||||||
|
</pre>
|
||||||
|
* When a function's argument list wraps around to a next line, you should indent that next line by either the normal width or enough spaces to align it with the arguments on the previous line.
|
||||||
* All declarations in a block must be at the beginning of that block.
|
* All declarations in a block must be at the beginning of that block.
|
||||||
* You should put a blank line between a list of local variable declarations and the first line of code.
|
* You should put a blank line between a list of local variable declarations and the first line of code.
|
||||||
* You must use ANSI C comments (```/* */```); you must not use C++ comments (```//```).
|
* Always use curly braces even for single statements after ```if```, and the single statement should go into a new line.
|
||||||
* The normal indentation width should be four spaces.
|
* Use "cuddling" braces, ie the opening brace goes in the same line as the ```if```:
|
||||||
* When a function's argument list wraps around to a next line, you should indent that next line by either the normal width or enough spaces to align it with the arguments on the previous line.
|
<pre>
|
||||||
* When you add functions to an existing file, you should separate them by the same number of blank lines that separate the functions that already are in that file.
|
if (foo > 42) {
|
||||||
|
bar = 23;
|
||||||
(The next two rules will be changed at some time in the future; but, for now:)
|
}
|
||||||
|
</pre>
|
||||||
|
* Should the ```if``` statement be followed by an empty conditional block, there should be a comment telling why this is the case
|
||||||
|
<pre>
|
||||||
|
if (check()) {
|
||||||
|
/* nothing happened, do nothing */
|
||||||
|
}
|
||||||
|
</pre>
|
||||||
* You must separate function names and parameter/argument lists by one space.
|
* You must separate function names and parameter/argument lists by one space.
|
||||||
* When declaring/defining pointers, you must put the asterisk (```*```) next to the data type, with a space between it and the variable's name. Examples:
|
* When declaring/defining pointers, you must put the asterisk (```*```) next to the data type, with a space between it and the variable's name. Examples:
|
||||||
<pre>
|
<pre>
|
||||||
|
Loading…
Reference in New Issue
Block a user