source: trunk/CodingStyle.txt@ 536

Last change on this file since 536 was 459, checked in by root, 19 years ago

Add more

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.8 KB
Line 
1
2Coding Style Guide
3==================
4
5Line lengths
6
7 Try to keep lines less than 80 characters.
8
9 Break lines after logical separators
10
11 Vertically align like constructs
12
13Indents
14
15 Place function definition { in column 1
16
17 Place function definition } in column 1
18
19 Intent nested constructs by 2 characters
20
21 void func()
22 {
23 stmt
24 if (expr)
25 stmt2
26 }
27
28Tabs
29
30 Use only 8 column tabs
31
32Layouts
33
34 if (expr)
35 statement
36
37 // If expr and statement are brief
38 if (expr) statement
39
40 if (expr1) {
41 }
42 else {
43 }
44
45 // If expression must be wrapped
46 // align like constructs vertically
47 if (expr1 &&
48 expr2))
49 {
50 }
51
52 while (expr) {
53 }
54
55 for (expr; expr; expr) {
56 }
57
58 typedef struct {
59
60 } TYPENAME;
61
62Variable definitions
63
64 Define one per line
65
66 INT a;
67 INT b;
68
69 not
70
71 INT a,b;
72
73Spaces
74
75 Separate keywords from leading paren with 1 space
76
77 if (expr) dothis
78
79 No space between function name and leading paren
80 No space between last arg and trailing paren
81
82 func()
83
84 Follow separating commas and semicolons with a space
85
86 x = func(a, c)
87
88 Surround binary operators with a leading and trailing spaces
89
90 x = a + b
91
92 Try to avoid spurious internal and trailing whitespace
93
94Memory
95
96 - Check all malloc/realloc/strdup/DosAllocMem calls
97 Use xmalloc in non-time critical code
98 Use xrealloc in non-time critical code
99 Use xstrdup in non-time critical code
100
101 - Use xfree rather than free
102
103Windows
104
105 - Check all WinCreateWindow calls
106 - Check QWL_USER pointer data
107
108Error notifications
109
110 DosBeep(50,100) Alert user to operator error
111 Use only when failure reason is obvious
112
113 saymsg Alert user to operator error with popup
114
115 Runtime_Error Report "should not occur" errors
116 Dos_Error
117 Win_Error
118
119$Id: CodingStyle.txt 459 2006-08-24 05:10:24Z root $
Note: See TracBrowser for help on using the repository browser.