-
Notifications
You must be signed in to change notification settings - Fork 0
/
DEVCRAP.txt
75 lines (68 loc) · 2.42 KB
/
DEVCRAP.txt
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
75
OK, if you are a developer then you NEED to read this.
It contains conventions & stuff.
1. ifdef/ifndef/if should have at the end of it a comment like so after the ifdef on the line:
/* WHATEVER_VAR_SET */
For ifndef, we use /* not WHATEVER_VAR_NOT_SET */
For if, we just put in the thing verbatim.
For else, we put the converse.
2. For functions which can return an error, use int, and return 0 if there is no error.
If you really only have a generic error, just return -1.
If you have a specific error, return the (non-negative) error number.
3. For functions which don't take any parameters, make sure you have (void) in the parentheses.
4. On that matter, don't use old-style function declarations.
If you don't know what they are, that's good.
Stick the types inside the parentheses.
5. Use // comments inside functions, structs, enums, et cetera.
Only use /* */ comments outside of them.
Why? So we can just do a /* */ around code inside a function if we need to.
6. Under all (non-function) circumstances, only use { } if you have more than one line of code.
7. Use { } like so:
if(blah)
{
// foo
} else if(blah2) {
// bar
} else if(blah3) {
// baz
} else {
// they didn't invent another one
}
while(blah)
{
// xaimus
}
do
{
// MandraSigma
} while(blah);
for(i = 0; i < blah; i += athaudia)
{
// ant1
}
void play_like_strobe(void)
{
// TODO make this more evil
}
8. Prefix every function with a brief description in /* */ comments like so:
(in this case we just drop "void" parts):
/* play_like_strobe():
* Be a pain in the butt.
*/
/* playing_like_strobe = int check_evilness(int player_idx);
* Are we being horrible enough?
*/
9. CamelCase is AbsolutelyForbidden.
We use whatever_this_is_called on our variables_and_functions.
10. i++ is used on its own, NOT ++i.
Only use ++i if you NEED to read the value from it.
11. With standards against my will, it will be spelt color.
12. THIS *MUST NOT* RUN IN FULLSCREEN BY DEFAULT.
Why? Because otherwise I get the rather charming
Out of Range
message on my monitor.
13. Function prototypes inside a header will have their variable names removed.
14. WE ARE *ABSOLUTELY #NOT#* going to make *ANY* attempt *WHATSOEVER* for MSVC++ support.
Tell those users to use a real compiler.
15. Everything is little-endian where possible.
16. Whitespace goes AFTER the # in a preprocessor statement.
17. Packed structs/unions use PACKED_PRE and PACKED_SUF.