123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398 |
- .TH 2C 1
- .SH NAME
- 0c, 1c, 2c, 4c, 5c, 6c, 7c, 8c, 9c, kc, qc, vc, xc \- C compilers
- .SH SYNOPSIS
- .B 2c
- [
- .I option ...
- ]
- [
- .I file ...
- ]
- .br
- etc.
- .SH DESCRIPTION
- These commands compile the named C
- .I files
- into object files for the corresponding architecture.
- Associated with each compiler is a string
- .IR objtype :
- .TP 1.5i
- .B "0c spim
- little-endian MIPS 4000 family
- .TP
- .B "1c 68000
- Motorola MC68000
- .TP
- .B "2c 68020
- Motorola MC68020
- .TP
- .B "4c mips2
- big-endian MIPS 4000 family
- .TP
- .B "5c arm
- ARM 7500
- .TP
- .B "6c 960
- Intel i960
- .TP
- .B "7c alpha
- Digital Alpha APX
- .TP
- .B "8c 386
- Intel i386, i486, Pentium, etc.
- .TP
- .B "9c 29000
- AMD 29000 family
- .TP
- .B "kc sparc
- Sun SPARC
- .TP
- .B "qc power
- Power PC,
- .TP
- .B "vc mips
- big-endian MIPS 3000 family
- .TP
- .B "xc 3210
- AT&T DSP 3210.
- .PP
- The compilers handle most preprocessing directives themselves; a complete
- preprocessor is available in
- .IR cpp (1),
- which must be run separately.
- .PP
- Let the first letter of the compiler name be
- .IR O =
- .BR 0 ,
- .BR 1 ,
- .BR 2 ,
- .BR 4 ,
- .BR 5 ,
- .BR 6 ,
- .BR 7 ,
- .BR 8 ,
- .BR 9 ,
- .BR k ,
- .BR q ,
- .BR v ,
- or
- .BR x .
- The output object files end in
- .RI . O .
- The letter is also the prefix of related programs:
- .IB O a
- is the assembler,
- .IB O l
- is the loader.
- Plan 9 conventionally sets the
- .B $objtype
- environment variable to the
- .I objtype
- string appropriate to the current machine's type.
- Plan 9 also conventionally has
- .RI / objtype
- directories, which contain among other things:
- .BR include ,
- for machine-dependent include files;
- .BR lib ,
- for public object code libraries;
- .BR bin ,
- for public programs;
- and
- .BR mkfile ,
- for preconditioning
- .IR mk (1).
- .PP
- The compiler options are:
- .TP 1i
- .BI -o " obj"
- Place output in file
- .I obj
- (allowed only if there is just one input file).
- Default is to take the last element of the input file name,
- strip any trailing
- .BR .c ,
- and append
- .RI . O .
- .TP
- .B -w
- Print warning messages about unused variables, etc.
- .TP
- .B -B
- Accept functions without a new-style
- ANSI C function prototype.
- By default, the compilers reject functions
- used without a defined prototype,
- although ANSI C permits them.
- .TP
- .BI -D\*S name=def
- .br
- .ns
- .TP
- .BI -D \*Sname
- Define the
- .I name
- to the preprocessor,
- as if by
- .LR #define .
- If no definition is given, the name is defined as
- .LR 1 .
- .TP
- .BI -F
- Enable type-checking of calls to
- .IR print (2)
- and other formatted print routines. See the discussion
- of extensions, below.
- .TP
- .BI -I \*Sdir
- An
- .L #include
- file whose name does not begin with
- slash
- or is enclosed in double quotes
- is always
- sought first in the directory
- of the
- .I file
- argument. If this fails, or the name is enclosed in
- .BR <> ,
- it is then sought
- in directories named in
- .B -I
- options,
- then in
- .BR /sys/include ,
- and finally in
- .BR /$objtype/include .
- .TP
- .B -N
- Suppress automatic registerization and optimization.
- .TP
- .B -S
- Print an assembly language version of the object code
- on standard output as well as generating the
- .RI . O
- file.
- .TP
- .B -V
- By default, the compilers are non-standardly lax about type equality between
- .B void*
- values and other pointers; this flag requires ANSI C conformance.
- .TP
- .B -p
- Invoke a standard ANSI C preprocessor before compiling.
- .TP
- .B -a
- Instead of compiling, print on standard output acid functions (see
- .IR acid (1))
- for examining structures declared in the source files.
- .TP
- .B -aa
- Like
- .B -a
- except suppress information about structures
- declared in included header files.
- .PP
- The compilers support several extensions to ANSI C:
- .TP
- \-
- A structure or union may contain unnamed substructures and subunions.
- The fields of the substructures or
- subunions 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 promotes
- the type and adjusts the pointer value to point at the substructure.
- If the unnamed structure or union is of a type with a tag name specified by a
- .B typedef
- statement,
- the unnamed structure or union can be explicitly referenced
- by <struct variable>.<tagname>.
- .TP
- \-
- A structure value can be formed with an expression such as
- .EX
- (struct S){v1, v2, v3}
- .EE
- where the list elements are values for the fields of struct
- .BR S .
- .TP
- \-
- Array initializers can specify the indices of the array in square
- brackets, as
- .EX
- int a[] = { [3] 1, [10] 5 };
- .EE
- which initializes the third and tenth elements of the eleven-element array
- .BR a .
- .TP
- \-
- Structure initializers can specify the structure element by using the name
- following a period, as
- .EX
- int struct { int x; int y; } s = { .y 1, .x 5 };
- .EE
- which initializes elements
- .B y
- and then
- .B x
- of the structure
- .BR s .
- These forms also accept the new ANSI C notation, which includes an equal sign:
- .EX
- int a[] = { [3] = 1, [10] = 5 };
- int struct { int x; int y; } s = { .y = 1, .x = 5 };
- .EE
- .TP
- \-
- A global variable can be dedicated to a register
- by declaring it
- .B "extern register"
- in
- .I all
- modules and libraries.
- .TP
- \-
- A
- .B #pragma
- of the form
- .EX
- #pragma lib "libbio.a"
- .EE
- records that the program needs to be loaded with file
- .BR /$objtype/lib/libbio.a ;
- such lines, typically placed in library header files, obviate the
- .B -l
- option of the loaders. To help identify files in non-standard directories,
- within the file names in the
- .B #pragmas
- the string
- .B $M
- represents the name of the architecture
- (e.g.,
- .BR mips )
- and
- .B $O
- represents its identifying character
- (e.g.,
- .BR v ).
- .TP
- \-
- A
- .B #pragma
- of the form
- .EX
- #pragma varargck argpos error 2
- .EE
- tells the compiler that the second argument to
- .B error
- is a
- .BR print -like
- format string (see
- .IR print (2))
- that identifies the handling of subsequent arguments.
- The
- .B #pragma
- .EX
- #pragma varargck type "s" char*
- .EE
- says that the format verb
- .B s
- processes an argument of type
- .BR char *.
- The
- .B #pragma
- .EX
- #pragma varargck flag 'c'
- .EE
- says that
- .B c
- is a flag character.
- These
- .B #pragmas
- are used, if the
- .B -F
- option is enabled, to type-check calls to
- .B print
- and other such routines.
- .TP
- \-
- The C++ comment
- .RB ( //
- to end of line)
- is accepted as well as the normal
- convention of
- .B /*
- .BR */ .
- .TP
- \-
- The compilers accept
- .B long
- .B long
- variables as a 64-bit type.
- The standard header typedefs this to
- .BR vlong .
- Arithmetic on
- .B vlong
- values is usually emulated by a run-time library.
- .SH EXAMPLE
- For the 68020, produce a program
- .B prog
- from C files
- .BR main.c
- and
- .BR sub.c :
- .IP
- .EX
- 2c -FVw main.c sub.c
- 2l -o prog main.2 sub.2
- .EE
- .SH FILES
- .TF /$objtype/include
- .TP
- .B /sys/include
- system area for machine-independent
- .B #include
- directives.
- .TP
- .B /$objtype/include
- system area for machine-dependent
- .B #include
- directives.
- .SH SOURCE
- .TF /sys/src/cmd/2c,\ etc.
- .TP
- .B /sys/src/cmd/cc
- machine-independent part
- .TP
- .BR /sys/src/cmd/2c ,\ etc.
- machine-dependent part
- .SH "SEE ALSO"
- .IR 2a (1),
- .IR 2l (1),
- .IR cpp (1),
- .IR mk (1),
- .IR nm (1),
- .IR pcc (1),
- .IR db (1),
- .IR acid (1),
- .PP
- Rob Pike,
- ``How to Use the Plan 9 C Compiler''
- .SH BUGS
- The i960 compiler has been used only to program one I/O controller
- and is certainly buggy.
- .PP
- The default preprocessor only handles
- .LR #define ,
- .LR #include ,
- .LR #undef ,
- .LR #ifdef ,
- .LR #line ,
- and
- .LR #ifndef .
- For a full ANSI preprocessor, use
- the
- .B p
- option.
|