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