497 lines · 9.3 KB · Text
RawDownload
.TH 2C 1.SH NAME0c, 1c, 2c, 5c, 6c, 7c, 8c, kc, qc, vc \- C compilers.SH SYNOPSIS.B 2c[.I option ...][.I file ...].bretc..SH DESCRIPTIONThese commands compile the named C.I filesinto object files for the corresponding architecture.If there are multiple C.IR files ,the compilers will attempt to keep.B $NPROCcompilations running concurrently.Associated with each compiler is a string.IR objtype ,for example.TF "6c amd64 ".PD.TP.B "0c spimlittle-endian MIPS 3000 family.TP.B "1c 68000Motorola MC68000.TP.B "2c 68020Motorola MC68020.TP.B "5c armlittle-endian ARM.TP.B "6c amd64AMD64 and compatibles (e.g., Intel EM64T).TP.B "7c alphaDigital Alpha APX.TP.B "8c 386Intel i386, i486, Pentium, etc..TP.B "kc sparcSun SPARC.TP.B "qc powerPower PC.TP.B "vc mipsbig-endian MIPS 3000 family.PPThe compilers handle most preprocessing directives themselves; a completepreprocessor is available in.IR cpp (1),which must be run separately..PPLet the first letter of the compiler name be.IR O =.BR 0 ,.BR 1 ,.BR 2 ,.BR 5 ,.BR 6 ,.BR 7 ,.BR 8 ,.BR k ,.BR q ,or.BR v .The output object files end in.RI . O .The letter is also the prefix of related programs:.IB O ais the assembler,.IB O lis the loader.Plan 9 conventionally sets the.B $objtypeenvironment variable to the.I objtypestring appropriate to the current machine's type.Plan 9 also conventionally has.RI / objtypedirectories, 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)..PPThe compiler options are:.TF Dname.PD.TP.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 -wPrint warning messages about unused variables, etc..TP.B -BAccept functions without a new-styleANSI C function prototype.By default, the compilers reject functionsused without a defined prototype,although ANSI C permits them..TP.BI -D\*S name=def.br.ns.TP.BI -D \*SnameDefine the.I nameto the preprocessor,as if by.LR #define .If no definition is given, the name is defined as.LR 1 ..TP.BI -FEnable type-checking of calls to.IR print (2)and other formatted print routines.  See the discussionof extensions, below..TP.BI -I \*SdirAn.L #includefile whose name does not begin withslashor is enclosed in double quotesis alwayssought first in the directoryof the.I fileargument.  If this fails,the.I -.flag is given or the name is enclosed in.BR <> ,it is then soughtin directories named in.B -Ioptions,then in.BR /sys/include ,and finally in.BR /$objtype/include ..TP.B -.Suppress the automatic searching for include files inthe directory of the file argument..TP.B -NSuppress automatic registerization and optimization..TP.B -SPrint an assembly language version of the object codeon standard output as well as generating the.RI . Ofile..TP.B -TPass type signatures on all external and global entities.The signature is based on the C.B signofoperator.See.IR dynld (2)..TP.B -VBy 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 -pInvoke a standard ANSI C preprocessor before compiling..TP.B -aInstead of compiling, print on standard output acid functions (see.IR acid (1))for examining structures declared in the source files..TP.B -aaLike.B -aexcept suppress information about structuresdeclared in included header files..TP.B -nWhen used with.B -aor.BR -aa ,places acid functions in.IB file .acidfor input.IB file .c ,and not on standard output..PPThe compilers support several extensions to ANSI C:.TF \|.PD.TP\-A structure or union may contain unnamed substructures and subunions.The fields of the substructures orsubunions can then be used as if they were members of the parentstructure or union (the resolution of a name conflict is unspecified).When a pointer to the outer structure or union is used in a contextthat is only legal for the unnamed substructure, the compiler promotesthe 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 typedefstatement,the unnamed structure or union can be explicitly referencedby <struct variable>.<tagname>..TP\-A structure value can be formed with an expression such as.EX    (struct S){v1, v2, v3}.EEwhere the list elements are values for the fields of struct.BR S ..TP\-Array initializers can specify the indices of the array in squarebrackets, as.EX    int a[] = { [3] 1, [10] 5 };.EEwhich initializes the third and tenth elements of the eleven-element array.BR a ..TP\-Structure initializers can specify the structure element by using the namefollowing a period, as.EX    struct { int x; int y; } s = { .y 1, .x 5 };.EEwhich initializes elements.B yand then.B xof 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 };    struct { int x; int y; } s = { .y = 1, .x = 5 };.EE.TP\-A global variable can be dedicated to a registerby declaring it.B "extern register"in.I allmodules and libraries..TP\-A.B #pragmaof the form.EX    #pragma lib "libbio.a".EErecords 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 -loption of the loaders.  To help identify files in non-standard directories,within the file names in the.B #pragmasthe string.B $Mrepresents the name of the architecture(e.g.,.BR mips )and.B $Orepresents its identifying character(e.g.,.BR v )..TP\-A.B #pragmaof the form.EX    #pragma varargck argpos error 2.EEtells the compiler that the second argument to.B erroris a.BR print -likeformat string (see.IR print (2))that identifies the handling of subsequent arguments.The.B #pragma.EX    #pragma varargck type "s" char*.EEsays that the format verb.B sprocesses an argument of type.BR char *.The.B #pragma.EX    #pragma varargck flag 'c'.EEsays that.B cis a flag character.These.B #pragmasare used, if the.B -Foption is enabled, to type-check calls to.B printand other such routines..TP\-A.B #pragmawith any of the following forms:.EX    #pragma incomplete \fItype\fP    #pragma incomplete struct \fItag\fP    #pragma incomplete union \fItag\fP.EEwhere.I typeis a.BR typedef 'dname for a structure or union type, and.I tagis a structure or union tag,tells the compiler thatthe corresponding typeshould have its signature calculated as an incomplete typeeven if it is subsequently fully defined.This allows the type signature mechanism to work in the presenceof opaque types declared in header files, with their full definitionsvisible only to the code which manipulates them.With some imported software it might be necessary to turn off thesignature generation completely for a large body of code (typicallyat the start and end of a particular include file).If.I typeis the word.BR _off_ ,signature generation is turned off; if.I typeis the word.BR _on_ ,the compiler will generate signatures..TP\-The C++ comment.RB ( //to end of line)is accepted as well as the normalconvention of.B /*.BR */ ..TP\-The compilers accept.B long.B longvariables as a 64-bit type.The standard header typedefs this to.BR vlong .Arithmetic on.B  vlongvalues is usually emulated by a run-time library,though in at least.IR 8c ,only division and modulus use the run-time libraryand the other operators generate in-line code(and.I uvlong-expression.I divison-or-modulus.BI "(1<<" constant )will turn into in-line bit operations,as is done for shorter.I unsignedexpressions)..SH EXAMPLEFor the 68020, produce a program.B progfrom C files.BR main.cand.BR sub.c :.IP.EX2c -FVw main.c sub.c2l -o prog main.2 sub.2.EE.SH FILES.TF /$objtype/include.TP.B /sys/includesystem area for machine-independent.B #includedirectives..TP.B /$objtype/includesystem area for machine-dependent.B #includedirectives..SH SOURCE.TF /sys/src/cmd/2c,\ etc..TP.B /sys/src/cmd/ccmachine-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).\" .IR ansitize (1).PPRob Pike,``How to Use the Plan 9 C Compiler''.SH BUGSThe list of compilers given above is only partial,not all architectures are supported on all systems,some have been retired and someare provided by third parties..PPThe default preprocessor only handles.LR #define ,.LR #include ,.LR #undef ,.LR #ifdef ,.LR #line ,and.LR #ifndef .For a full ANSI preprocessor, usethe.B poption..PPThe default search order for include filesdiffers to that of.IR cpp (1)..PPSome features of C99, the 1999 ANSI C standard,are implemented..PP.B switchexpressions may not be either signedness of.B vlongon 32-bit architectures.RI ( 8cat least)..PPThe implementation of.B vlongassignment can use a static locationand this can be disturbed by interrupts(e.g., notes).RI ( 8cat least).