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
RevLine 
[392]1
2Coding Style Guide
[459]3==================
[392]4
[459]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
[392]13Indents
14
[459]15 Place function definition { in column 1
[392]16
[459]17 Place function definition } in column 1
[392]18
[459]19 Intent nested constructs by 2 characters
[392]20
[459]21 void func()
22 {
23 stmt
24 if (expr)
25 stmt2
26 }
[392]27
[459]28Tabs
[392]29
[459]30 Use only 8 column tabs
[392]31
[459]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
[392]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
[459]105 - Check all WinCreateWindow calls
[392]106 - Check QWL_USER pointer data
107
[459]108Error notifications
[392]109
[459]110 DosBeep(50,100) Alert user to operator error
111 Use only when failure reason is obvious
[392]112
[459]113 saymsg Alert user to operator error with popup
[392]114
[459]115 Runtime_Error Report "should not occur" errors
116 Dos_Error
117 Win_Error
118
[392]119$Id: CodingStyle.txt 459 2006-08-24 05:10:24Z root $
Note: See TracBrowser for help on using the repository browser.