-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcstyle.html
89 lines (78 loc) · 3.4 KB
/
cstyle.html
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-2">
<title>C style for your source code</title>
<meta http-equiv="Content-type" charset="iso-8859-2">
<script type="text/javascript">
function write_last_mod ()
{
var loc = new String (document.location);
if (loc.match (/\.html($|\?.*)|\/$/)) {
var last_modified = new Date (document.lastModified);
// var date_stamp = last_modified.toDateString ();
// document.writeln (date_stamp);
document.writeln (last_modified);
}
}
</script>
</head>
<body bgcolor="#ffffff">
<center>
<table width="100%" cellspacing="2" cellpadding="3">
<tbody><tr>
</tr><tr valign="middle" bgcolor="lightgreen" align="center">
<td><font size="+5" color="black">Use a good C style to format your source
code files</font>
</td></tr></tbody></table>
</center>
<p>A good C style of the source code you write represents you. You
will be judged by other people by the way your source code looks.
Always try to write beautiful code.
</p><p>There are a few possible good C styles. We recommend one that is well
documented and comes with a Perl script for checking. The script does not catch
everything but is good enough. However, in order to use it properly, <b>you
need to start with following the C style after reading the document below, then
check the resulting code with the script.</b> It will not work well if you
start with non-conforming code and keep fixing the warnings until the script no
longer reports anything. In that case, the resulting code may still be pretty
bad style-wise.
</p><p>The <b>recommended C style is used for the Oracle Solaris operating
system source code</b> and is explained in a short (~20 pages) nicely formatted
document: <a href="./cstyle.ms.pdf">C Style and Coding Standards for SunOS</a>.
</p><p>The <a href="./cstyle.pl">cstyle.pl</a> for verification is provided, and
it works like this:
</p><pre>$ chmod u+x cstyle.pl
$ ./cstyle.pl src/exams/parallel-udp/*.c
src/exams/parallel-udp/client.c: 12: missing space between keyword and paren
src/exams/parallel-udp/client.c: 13: missing space between keyword and paren
src/exams/parallel-udp/client.c: 25: line > 80 characters
src/exams/parallel-udp/server.c: 14: missing space between keyword and paren
src/exams/parallel-udp/server.c: 15: missing space between keyword and paren
src/exams/parallel-udp/server.c: 25: missing space between keyword and paren
src/exams/parallel-udp/server.c: 45: line > 80 characters
src/exams/parallel-udp/server.c: 50: line > 80 characters
src/exams/parallel-udp/server.c: 56: line > 80 characters
</pre>
<p>More C coding styles:
<ul>
<li><a
href="https://www.kernel.org/doc/html/v4.10/process/coding-style.html">Linux
kernel coding style</a>
<li>from OpenBSD, see the <a href="https://man.openbsd.org/style">style(9)</a>
manual page for more information.
<li><a href="https://www.gnu.org/prep/standards/standards.html#Writing-C">GNU C
coding standards</a>
<li><a
href="https://www.freebsd.org/cgi/man.cgi?query=style&apropos=0&sektion=9&manpath=FreeBSD+12.1-RELEASE+and+Ports&arch=default&format=html">FreeBSD
kernel C coding style</a>
<li><a href="https://www.openssl.org/policies/codingstyle.txt">OpenSSL C coding
style</a>
<li><a href="https://httpd.apache.org/dev/styleguide.html">Apache C style
guide</a>
</ul>
</p><p></p><hr>
Last changed:
<script>
write_last_mod ();
</script>
</body></html>