annotate docs/ccguide/chap1.chapter @ 472:f0c8d53e5a50

entered: chdir chmod qsort strass toupper tsleep wait
author roug
date Sun, 06 Oct 2002 09:10:36 +0000
parents 60b821f18853
children c43b678c0055
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
466
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
1 <chapter>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
2 <title>The C Compiler System</title>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
3
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
4 <section>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
5 <title>Introduction</title>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
6 <para>
468
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
7 The "C" programming language is rapidly growing in popularity
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
8 and seems destined to become one of the most popular programming
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
9 languages used for microcomputers. The rapid rise in the use of C
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
10 is not surprising. C is an incredibly versatile and efficient
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
11 language that can handle tasks that previously would have required
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
12 complex assembly language programming.
466
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
13 </para>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
14
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
15 </section>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
16 <section>
468
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
17 <title>The Language Implementation</title>
466
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
18 <para>
468
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
19 OS-9 C is implemented almost exactly as described in 'The C
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
20 Programming Language' by Kernighan and Ritchie (hereafter referred
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
21 to as K&amp;R).
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
22 </para>
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
23 <para>
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
24 Allthough this version of C follows the specification faithfully,
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
25 there are some differences. The differences mostly reflect
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
26 parts of C that are obsolete or the constraints imposed by memory
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
27 size limitations.
466
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
28 </para>
472
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
29
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
30 </section>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
31 <section>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
32 <title>Compiler Option Flags</title>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
33 <para>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
34 The compiler recognizes several command-line option flags which
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
35 modify the compilation process where needed. All flags are
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
36 recognized before compilation commences so the flags may be placed
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
37 anywhere on the command line. Flags may be ran together as in "-ro",
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
38 except where a flag is followed by something else; see "-f=" and
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
39 "-d" for examples.
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
40 </para>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
41 <para>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
42 -A
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
43 suppresses assembly, leaving the output as assembler code in a
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
44 file whose name is postfixed ".a".
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
45 </para>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
46 <para>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
47 -E=&lt;number&gt;
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
48 Set the edition number constant byte to the number given. This is
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
49 an OS-9 convention for memory modules.
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
50 </para>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
51 <para>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
52 -O
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
53 inhibits the assembly code optimizer pass. The optimizer will
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
54 shorten object code by about 11% with a comparable increase in speed
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
55 and is recommended for production versions of de-bugged programs.
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
56 </para>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
57 <para>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
58 -P
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
59 invokes the profiler to generate function frequency
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
60 statistics after program execution.
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
61 </para>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
62 <para>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
63 -R
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
64 suppresses linking library modules into an executable program.
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
65 Outputs are left in files with postfixes ".r".
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
66 </para>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
67 <para>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
68 -M=&lt;memory size&gt;
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
69 will instruct the linker to allocate &lt;memory size&gt;
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
70 for data, stack, and parameter area. Memory size may be expressed
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
71 in pages (an integer) or in kilobytes by appending "k" to an
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
72 integer. For more details of the use of this option, see the
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
73 "Memory Management" section of this manual.
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
74 </para>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
75 <para>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
76 -L=&lt;filename&gt;
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
77 specifies a library to be searched by the linker
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
78 before the Standard Library and system interface.
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
79 </para>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
80 <para>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
81 -F=&lt;path&gt;
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
82 overrides the above output file naming. The output file
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
83 will be left with &lt;filename&gt; as its name. This flag does not make
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
84 sense in multiple source mode, and either the -a or -r flag is also
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
85 present. The module will be called the last name in &lt;path&gt;.
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
86 </para>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
87 <para>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
88 -C
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
89 will output the source code as comments with the assembler code.
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
90 </para>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
91 <para>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
92 -S
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
93 stops the generation of stack-checking code. -S should only be
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
94 used with great care when the appication is extremely time-critical
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
95 and when the use of the stack by compiler generated code is fully
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
96 understood.
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
97 </para>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
98 <para>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
99 -D&lt;identifier&gt;
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
100 is equivalent to "#define &lt;identifier&gt;" written in
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
101 the source file. -D is useful where different versions of a program
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
102 are maintained in one source file and differentiated by means of the
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
103 "#ifdef" of "#ifndef" pre-processor directives. If the &lt;identifier&gt;
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
104 is used as a macro for expansion by the pre-processor, "1"(one) will
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
105 be the expanded "value" unless the form "-d&lt;identifier&gt;=&lt;string&gt;" is
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
106 used in which case the expansion will be &lt;string&gt;.
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
107 </para>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
108 <table frame="none">
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
109 <title>Command Line and Option Flag Examples</title>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
110 <tgroup cols="3">
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
111 <colspec colwidth="1.5in" colname="c1">
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
112 <colspec colwidth="1.5in" colname="c2">
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
113 <colspec colwidth="1.5in" colname="c3">
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
114 <thead>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
115 <row>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
116 <entry>command line</entry>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
117 <entry>action</entry>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
118 <entry>output file(s)</entry>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
119 </row>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
120 </thead>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
121 <tbody>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
122 <row>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
123 <entry>cc prg.c</entry>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
124 <entry>compile to an executable program</entry>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
125 <entry>prg</entry>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
126 <entry></entry>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
127 </row>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
128 <row>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
129 <entry>cc prg.c -a</entry>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
130 <entry>compile to assembly language source code</entry>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
131 <entry>prg.a</entry>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
132 </row>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
133 <row>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
134 <entry>cc prg.c -r</entry>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
135 <entry>compile to relocatable module</entry>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
136 <entry>prg.r</entry>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
137 </row>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
138 <row>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
139 <entry>cc prg1.c prg2.c prg3.c</entry>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
140 <entry>compile to executable program</entry>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
141 <entry>prg1.r, prg2.r, prg3.r, output</entry>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
142 </row>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
143 <row>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
144 <entry>cc prg1.c prg2.a prg3.r</entry>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
145 <entry>compile prg1.c, assemble prg2.a and combine all into
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
146 and executable program</entry>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
147 <entry>prg1.r, prg2.r</entry>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
148 </row>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
149 <row>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
150 <entry>cc prg1.c prg2.c -a</entry>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
151 <entry>compile to assembly language source code</entry>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
152 <entry>prg1.a, prg2.a</entry>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
153 </row>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
154 <row>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
155 <entry>cc prg1.c prg2.c -f=prg</entry>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
156 <entry>compile to executable program</entry>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
157 <entry>prg</entry>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
158 </row>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
159 </tbody>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
160 </tgroup>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
161 </table>
f0c8d53e5a50 entered: chdir chmod qsort strass toupper tsleep wait
roug
parents: 468
diff changeset
162
466
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
163 </section>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
164 </chapter>