• Aucun résultat trouvé

Compiling and Linking C Programs

Dans le document III CP·6 (Page 23-26)

The C compiler is invoked by the following IBEX command:

!

cc

jsource]j, update] j{oNiOVERiINTO} jobjectjf, list]] j(options)]

where:

source specifies the file that contains C source code.

update specifies a file containing updates to the source file.

ON requests an error if the object or list file currently exists.

OVER specifies that the object or list file is to be overwritten if it exists.

INTO specifies that the object or list file is to be extended if it exists.

object specifies the disk file to contain the generated object code.

list specifies the file to receive the generated listing.

options specifies one or more compiler options, separated by commas. (These are described in the next subsection.)

Figure 1-1 provides an example of entering, compiling, linking, and running a C program.

!build hello:c EDIT E02 here

1.000 maine) {

2.000 printf(tlHello, world!\n tl );

3.000 } 4.000

!CC hello:c over hello:o,*:ls

CC.BOO here at 15:02 Tue Jan 2 1990

!LINK hello:o over hello LINK E02 here

* :SHARED_C.:SYS (Shared Library) associated.

* No linking errors.

* Total program size

=

3K.

!hello.

Hello, world!

Figure 1-1. C Program Example

HA17-00 Compiling and Linking C Programs 1-3

Introduction to the C Compiler special calling sequence that significantly speeds up the execution. If no function names are specified, all functions which the compiler knows how to build in are recognized; otherwise, only those specific functions will be recognized. If the source file includes the header file which defines these functions, they will be built in by default without specifying this option (see Section 9, Use of Library Functions).

The possible builtin functions include the following: abs, atan, atan2, cos, exp, fabs, log, log10, memchr,memcmp,memcpy, memmove, memrchr,memset, pow, sin, sinh, sqrt, strcat, strchr, strcmp, strcpy, strlen, tan, and tanh.

CP6SRCH requests that include files be located by strictly following the search list in the order specified. The default is CP6SRCH.

DEF /INE} (namel/=textJ/, name2/=text), ...

j)

defines preprocessor variables with the optionally provided text. text may be a number, an identifier, or a single quoted string.

DMAP requests a data map for declared variables. The data map displays the location, type, and size for each variable.

KR requests Kernighan and Ritchie language where ANSI differs.

LND/IRECT} requests the preprocessor to include line number directives. The default is LND lRECT . in certain library functions. If no function names are specified, all functions which the compiler knows how to build in are assumed; otherwise, only those specific functions will not be built in. Even if the source file includes the header file which defines these functions, they will not be built in. The possible built-in function names are listed under the BUILTIN option.

NDEF fINE} (name

f,

name}) causes the named predefined preprocessor variables to be undefined. The variable names affected may be TM_l66, TS_CP6, __ l66 __ , _CP6_, __ lINE __ , __ FIlE __ , __ DATE __ , __ TlME __ , and __ STDC __ .

NlND!IRECT} causes the preprocessor to suppress the inc;lusion of line number direc-tives. The default is lNDlRECT.

1-4 C Compiler Options HA17-00

Introduction to the C Compiler NLO suppresses listing of the generated code. The default is NLO.

NLS suppresses listing of the source code. The default is LS.

NLU suppresses listing of the updates. The default is NLU.

NOPT!IMIZEj ! (opt!, opt, ... j)

j

requests that the compiler not perform various optimizations. If the individual optimizations are not explicitly specified, then the compiler does not perform any of its possible optimizations. The list of optimizations is the same as for the OPTIMIZE option.

NOU suppresses generation of an object file. The default is OU.

NPMAP suppresses the procedure map. The default is NPMAP.

NUl requests that the compiler not include updates. The default is NUl.

NWAfRNj suppresses the listing of warning messages. The default is WARN.

OPT!IMIZEj ! (opt!, opt, ... j)

j

requests that the compiler perform various opti-mizations. If the individual optimizations are not explicitly requested, then the compiler performs all of its optimizations. The individual optimizations are as fol-lows: PEEPjHOLEj, INL!INE], SUBE!XPR], STR/ENGTHj, LOOPB{RANCH], CON!STANT], PRO/PAGATION], and REG!ISTERSj. By default, the PEEPHOLE and REGISTER opti-mizations are performed.

OPTUI reports no error when an update file does not exist.

OU requests generation of an object unit. (This option may not be specified with the PREPROCESS option.) The default is OU.

PMAP requests a procedure map for functions. The procedure map displays the location, statement type, and approximate execution cost for each statement. The default is NPMAP.

PREP /ROCESS

j

causes the compiler to preprocess the source and write it through M$OU.

{S/EAjRCHISEAR!CHj} (jid!,jid, ... j) requests that the compiler locate include files by searching the specified accounts. If jid includes a filename part, then that part is prefixed to the include file name (or the include file name replaces the ? character in the jid). The compiler always adds the account :LIBRARY to the end of the search list. The default is CP6SRCH.

S/TATICj F/UNCTIONj SIUFFIXj = 'string' requests that string be used as the suffix added to static function names to make them unique. By default, CP-6 C generates a unique name for every static function by using the name of the first nonstatic function or, if there are no nonstatic functions, the name of an extern variable defined in the file.

STR!INGS

j

= {READ !ONL y jIWRITE!ABLEj} requests that the compiler put strings in write-protected memory or writeable memory. By default, a C program may not alter a character string constant. The default is STRINGS=READONL Y.

UI requests that the compiler include updates. The default is NUl unless the UI filename is specified on the command line.

HA17-00 C Compiler Options 1-5

Introduction to the C Compiler

UNIXSRCH requests that nested include files be located by the UNIX method. If the file name is enclosed in angle brackets «filename», then the search is the same as for the CP6SRCH option. Otherwise, for file names enclosed in double quotes ("filename"), the search begins as if the search list were preceded by the search list entry used to locate the including source file. The default is CP6SRCH.

WA(RN

J

requests the listing of warnings for recoverable errors. The default is WARN.

Dans le document III CP·6 (Page 23-26)