|
|
1.1 root 1: .TH 2C 1
2: .SH NAME
3: 2c, 6c, 8c, kc, vc, xc \- C compilers
4: .SH SYNOPSIS
5: .B 2c
6: [
7: .I option ...
8: ]
9: [
10: .I file ...
11: ]
12: .br
13: .B 6c
14: [
15: .I option ...
16: ]
17: [
18: .I file ...
19: ]
20: .br
21: .B 8c
22: [
23: .I option ...
24: ]
25: [
26: .I file ...
27: ]
28: .br
29: .B kc
30: [
31: .I option ...
32: ]
33: [
34: .I file ...
35: ]
36: .br
37: .B vc
38: [
39: .I option ...
40: ]
41: [
42: .I file ...
43: ]
44: .br
45: .B xc
46: [
47: .I option ...
48: ]
49: [
50: .I file ...
51: ]
52: .SH DESCRIPTION
53: .IR 2c ,
54: .IR 6c ,
55: .IR 8c ,
56: .IR kc ,
57: .IR vc ,
58: and
59: .IR xc
60: compile the named C
61: .I files
62: into MC68020, i960, i386, SPARC, MIPS, and ATT3210 object files.
63: The compilers handle most preprocessing directives themselves; a complete
64: preprocessor is available in
65: .IR cpp (1),
66: which must be run separately.
67: .PP
68: Let the first letter of the compiler name be
69: .IR O =
70: .BR 2 ,
71: .BR 6 ,
72: .BR 8 ,
73: .BR k ,
74: .BR v ,
75: or
76: .BR x .
77: The output object files end in
78: .RI . O .
79: The letter is also the prefix of related programs:
80: .IB O a
81: is the assembler,
82: .IB O l
83: is the loader.
84: Associated with each compiler is a string
85: .IR objtype =
86: .BR 68020 ,
87: .BR 960 ,
88: .BR 386 ,
89: .BR sparc ,
90: .BR mips,
91: or
92: .BR 3210 .
93: Plan 9 conventionally sets the
94: .B $objtype
95: environment variable to the
96: .I objtype
97: string appropriate to the current machine's type.
98: Plan 9 also conventionally has
99: .RI / objtype
100: directories, which contain among other things:
101: .BR include ,
102: for machine-dependent include files;
103: .BR lib ,
104: for public object code libraries;
105: .BR bin ,
106: for public programs;
107: and
108: .BR mkfile ,
109: for preconditioning
110: .IR mk (1).
111: .PP
112: The compiler options are:
113: .TP 1i
114: .BI -o " obj"
115: Place output in file
116: .I obj
117: (allowed only if there is just one input file).
118: Default is to take the last element of the input file name,
119: strip any trailing
120: .BR .c ,
121: and append
122: .RI . O .
123: .TP
124: .B -w
125: Print warning messages about unused variables, etc.
126: .TP
127: .B -B
128: Accept functions without a new-style
129: ANSI C function prototype.
130: By default, the compilers reject functions
131: used without a defined prototype,
132: although ANSI C permits them.
133: .TP
134: .BI -D\*S name=def
135: .br
136: .ns
137: .TP
138: .BI -D \*Sname
139: Define the
140: .I name
141: to the preprocessor,
142: as if by
143: .LR #define .
144: If no definition is given, the name is defined as
145: .LR 1 .
146: .TP
147: .BI -I \*Sdir
148: An
149: .L #include
150: file whose name does not begin with
151: slash
152: or is enclosed in double quotes
153: is always
154: sought first in the directory
155: of the
156: .I file
157: argument. If this fails, or the name is enclosed in
158: .BR <> ,
159: it is then sought
160: in directories named in
161: .B -I
162: options,
163: then in
164: .BR /sys/include ,
165: and finally in
166: .BR /$objtype/include .
167: .TP
168: .B -N
169: Suppress automatic registerization and optimization.
170: .TP
171: .B -S
172: Print an assembly language version of the object code
173: on standard output as well as generating the
174: .RI . O
175: file.
176: .TP
177: .B -a
178: Instead of compiling, print on standard output acid functions (see
179: .IR acid (1))
180: for examining structures declared in the source files.
181: .TP
182: .B -aa
183: Like
184: .B -a
185: except suppress information about structures
186: declared in included header files.
187: .PP
188: The compilers support several extensions to ANSI C:
189: .TP
190: \-
191: A structure or union may contain unnamed substructures and subunions.
192: The fields of the substructures or
193: subunions can then be used as if they were members of the parent
194: structure or union (the resolution of a name conflict is unspecified).
195: When a pointer to the outer structure or union is used in a context
196: that is only legal for the unnamed substructure, the compiler promotes
197: the type and adjusts the pointer value to point at the substructure.
198: If the unnamed structure or union is of a type with a tag name specified by a
199: .B typedef
200: statement,
201: the unnamed structure or union can be explicitly referenced
202: by <struct variable>.<tagname>.
203: .TP
204: \-
205: A structure value can be formed with an expression such as
206: .EX
207: (struct S){v1, v2, v3}
208: .EE
209: where the list elements are values for the fields of struct
210: .BR S .
211: .TP
212: \-
213: Array initializers can specify the indices of the array in square
214: brackets, as
215: .EX
216: int a[] = { [3] 1, [10] 5 };
217: .EE
218: which initializes the third and tenth elements of the eleven-element array
219: .BR a .
220: .TP
221: \-
222: Structure initializers can specify the structure element by using the name
223: following a period, as
224: .EX
225: int struct { int x; int y; } s = { .y 1, .x 5 };
226: .EE
227: which initializes elements
228: .B y
229: and then
230: .B x
231: of the structure
232: .BR s .
233: .TP
234: \-
235: A global variable can be dedicated to a register
236: by declaring it
237: .B "extern register"
238: in
239: .I all
240: modules and libraries.
241: .TP
242: \-
243: A
244: .B #pragma
245: of the form
246: .EX
247: #pragma lib "libbio.a"
248: .EE
249: records that the program needs to be loaded with file
250: .BR /$objtype/lib/libbio.a ;
251: such lines, typically placed in library header files, obviate the
252: .B -l
253: option of the loaders. To help identify files in non-standard directories,
254: within the file names in the
255: .B #pragmas
256: the string
257: .B $M
258: represents the name of the architecture
259: (e.g.,
260: .BR mips )
261: and
262: .B $O
263: represents its identifying character
264: (e.g.,
265: .BR v ).
266: .TP
267: \-
268: The C++ comment
269: .RB ( //
270: to end of line)
271: is accepted as well as the normal
272: convention of
273: .B /*
274: .BR */ .
275: .TP
276: \-
277: The compilers accept
278: .B long
279: .B long
280: variables as a 64-bit type.
281: The standard header typedefs this to
282: .BR vlong .
283: The
284: .B vlong
285: runtime is slow.
286: .SH EXAMPLE
287: For the 68020, produce a program
288: .B prog
289: from C files
290: .BR main.c
291: and
292: .BR sub.c :
293: .IP
294: .EX
295: 2c -w main.c sub.c
296: 2l -o prog main.2 sub.2
297: .EE
298: .SH FILES
299: .TF /$objtype/include
300: .TP
301: .B /sys/include
302: system area for machine-independent
303: .B #include
304: directives.
305: .TP
306: .B /$objtype/include
307: system area for machine-dependent
308: .B #include
309: directives.
310: .SH SOURCE
311: .TF /sys/src/cmd/2c,\ etc.
312: .TP
313: .B /sys/src/cmd/cc
314: machine-independent part
315: .TP
316: .BR /sys/src/cmd/2c ,\ etc.
317: machine-dependent part
318: .SH "SEE ALSO"
319: .IR 2a (1),
320: .IR 2l (1),
321: .IR cpp (1),
322: .IR mk (1),
323: .IR nm (1),
324: .IR pcc (1),
325: .IR db (1),
326: .IR acid (1),
327: .PP
328: Rob Pike,
329: ``How to Use the Plan 9 C Compiler''
330: .SH BUGS
331: The i960 compiler has been used only to program one I/O controller
332: and is certainly buggy.
333: .PP
334: The preprocessor only handles
335: .LR #define ,
336: .LR #include ,
337: .LR #undef ,
338: .LR #ifdef ,
339: .LR #line ,
340: and
341: .LR #ifndef .
342: For a full ANSI preprocessor, use
343: .IR cpp (1)
344: on the files first.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.