1
+ <!DOCTYPE html>
2
+ < html > < head >
3
+ < meta http-equiv ="content-type " content ="text/html; charset=ISO-8859-2 ">
4
+ < title > C style for your source code</ title >
5
+ < meta http-equiv ="Content-type " charset ="iso-8859-2 ">
6
+ < script type ="text/javascript ">
7
+ function write_last_mod ( )
8
+ {
9
+ var loc = new String ( document . location ) ;
10
+ if ( loc . match ( / \. h t m l ( $ | \? .* ) | \/ $ / ) ) {
11
+ var last_modified = new Date ( document . lastModified ) ;
12
+ // var date_stamp = last_modified.toDateString ();
13
+ // document.writeln (date_stamp);
14
+ document . writeln ( last_modified ) ;
15
+ }
16
+ }
17
+ </ script >
18
+ </ head >
19
+
20
+ < body bgcolor ="#ffffff ">
21
+
22
+ < center >
23
+ < table width ="100% " cellspacing ="2 " cellpadding ="3 ">
24
+ < tbody > < tr >
25
+ </ tr > < tr valign ="middle " bgcolor ="lightgreen " align ="center ">
26
+ < td > < font size ="+5 " color ="black "> Use a good C style to format your source
27
+ code files</ font >
28
+ </ td > </ tr > </ tbody > </ table >
29
+ </ center >
30
+
31
+ < p > A good C style of of the source code you write represents you. You
32
+ will be judged by other people by the way your source code looks.
33
+ Always try to write beautiful code.
34
+
35
+ </ p > < p > There are a few possible good C styles. We recommend one that is
36
+ well documented and comes with a Perl script for checking. The script
37
+ does not catch everything but is pretty good.
38
+
39
+ </ p > < p > The < b > recommended C style is used for the Oracle Solaris operating
40
+ system source code</ b > and is explained in a short (~20 pages) nicely
41
+ formatted document: < a href ="http://mff.devnull.cz/cstyle/cstyle.ms.pdf "> C Style and Coding
42
+ Standards for SunOS</ a > .
43
+
44
+ </ p > < p > The < a href ="http://mff.devnull.cz/cstyle/cstyle.pl "> cstyle.pl</ a > for verification is provided,
45
+ and it works like this:
46
+
47
+ </ p > < pre > $ chmod u+x cstyle.pl
48
+ $ ./cstyle.pl src/exams/parallel-udp/*.c
49
+ src/exams/parallel-udp/client.c: 12: missing space between keyword and paren
50
+ src/exams/parallel-udp/client.c: 13: missing space between keyword and paren
51
+ src/exams/parallel-udp/client.c: 25: line > 80 characters
52
+ src/exams/parallel-udp/server.c: 14: missing space between keyword and paren
53
+ src/exams/parallel-udp/server.c: 15: missing space between keyword and paren
54
+ src/exams/parallel-udp/server.c: 25: missing space between keyword and paren
55
+ src/exams/parallel-udp/server.c: 45: line > 80 characters
56
+ src/exams/parallel-udp/server.c: 50: line > 80 characters
57
+ src/exams/parallel-udp/server.c: 56: line > 80 characters
58
+ </ pre >
59
+
60
+ < p > Another < b > very good C style is what the OpenBSD team uses</ b > , it is
61
+ very similar to the Solaris C style, there are some minor differencies.
62
+ Apparently they do not provide an automated checker. See the < a href ="https://man.openbsd.org/style "> style(9)</ a > manual page for more
63
+ information.
64
+
65
+ </ p > < p > </ p > < hr >
66
+ Last changed:
67
+ < script >
68
+ write_last_mod ( ) ;
69
+ </ script > Wed Oct 10 2018 11:23:57 GMT+0200 (CEST)
70
+
71
+
72
+
73
+
74
+ </ body > </ html >
0 commit comments