2C(1) 2C(1) NAME 2c, 6c, 8c, kc, vc, zc - C compilers SYNOPSIS 2c [ option ... ] [ name ... ] 6c [ option ... ] [ name ... ] 8c [ option ... ] [ name ... ] kc [ option ... ] [ name ... ] vc [ option ... ] [ name ... ] zc [ option ... ] [ name ... ] DESCRIPTION 2c, 6c, 8c, kc, vc, and zc compile the named C files into MC68020, i960, i386, SPARC, MIPS, and Hobbit object files. The compilers handle most preprocessing directives them- selves; a complete preprocessor is available in cpp(1), which must be run separately. Let the first letter of the compiler name be O= 2, 6, 8, k, v, or z. The output object files end in .O. The letter is also the prefix of related programs: Oa is the assembler, Ol is the loader. Associated with each compiler is a string objtype= 68020, 960, 386, sparc, mips, or hobbit. Plan 9 conventionally sets the $objtype environment variable to the objtype string appropriate to the current machine's type. Plan 9 also conventionally has /objtype directories, which contain among other things: include, for machine-dependent include files; lib, for public object code libraries; bin, for public programs; and mkfile, for preconditioning mk(1). The compiler options are: -o obj Place output in file obj (allowed only if there is just one input file). Default is to take the last element of the input pathname, strip any trailing .c, and append .O. -w Print warning messages about unused variables, etc. -A Complain about functions used without a new-style ANSI C function prototype. This option is on by default. -B Turn off the action of the -A flag. -Dname=def -Dname Define the name to the preprocessor, as if by `#define'. If no definition is given, the name is defined as `1'. Page 1 Plan 9 (printed 12/22/24) 2C(1) 2C(1) -Idir `#include' files whose names do not begin with `/' are always sought first in the directory of the file argument, then in directories named in -I options, then in /sys/include, and finally in /$objtype/include. -O Perform object code optimization. This option is on by default. -N Turn off the action of the -O flag. -S Print an assembly language version of the object code on standard output as well as generating the .O file. -sname Print on standard output a listing of the fields in structure or union name together with their offsets and some type information. This can be used in conjunction with the debugger (see db(1)). The compilers support several extensions to ANSI C: - A structure or union may contain unnamed substructures and subunions. The fields of the substructures or sub- unions can then be used as if they were members of the parent structure or union (the resolution of a name conflict is unspecified). When a pointer to the outer structure or union is used in a context that is only legal for the unnamed substructure, the compiler pro- motes the type and adjusts the pointer value to point at the substructure. - A structure value can be formed with an expression such as (struct S){v1, v2, v3} where the list elements are values for the fields of struct S. - Array initializers can specify the indices of the array in square brackets, as int a[] = { [3] 1, [10] 5 }; which initializes the third and tenth elements of the eleven-element array a. - A global variable can be dedicated to a register by declaring it extern register in all modules and libraries. - A #pragma of the form #pragma lib "libbio.a" records that the program needs to be loaded with file /$objtype/lib/libbio.a; such lines, typically placed in Page 2 Plan 9 (printed 12/22/24) 2C(1) 2C(1) library header files, obviate the -l option of the loaders. EXAMPLE For the 68020, produce a program prog from C files main.c and sub.c: 2c -w main.c sub.c 2l -o prog main.2 sub.2 FILES /sys/include system area for machine-independent #include directives. /$objtype/include system area for machine-dependent #include directives. SEE ALSO 2a(1), 2l(1), rl(1), mk(1), nm(1), db(1) Rob Pike, ``How to Use the Plan 9 C Compiler'' BUGS The i960 compiler has been used only to program one I/O con- troller and is certainly buggy. Bitfields are not supported in zc. The preprocessor only handles `#define', `#include', `#undef', `#ifdef', `#line', and `#ifndef'. For a full ANSI preprocessor, use cpp(1) on the files first. Page 3 Plan 9 (printed 12/22/24)