DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

c89(CP)


c89 -- compile standard C programs

Synopsis

   c89	[-c] [-D name[=value]]...  [-E] [-g] [-I directory]...
   	[-L directory]...  [-o outfile]
   	[-O][-s] [-U name]...  operand...

Description

The c89 utility is an interface to the standard C compilation system; it will accept source code conforming to the ISO C standard. The system conceptually consists of a compiler and link editor. The files referenced by operand arguments are compiled and linked to produce an executable file.

If the -c option is specified, for each pathname operand of the form file.c, the files $(basename operand).o are created as the result of successful compilation. If the -c option is not specified, it is unspecified whether such .o files are created or deleted for the file.c operands. If there are no options that prevent link editing (such as -c or -E), and all operands compile and link without error, the resulting executable file will be written according to the -o option (if present) or to the file a.out. The executable file will be created as specified in the XSH specification, except that the file permissions will be set to S_IRWXO | S_IRWXG | S_IRWXU and that the bits specified by the umask of the process will be cleared.

Standard libraries

The c89 utility recognizes the following -l operands for standard libraries:

-l c
This operand makes visible all library functions referenced in the XSH specification (except for those labelled X/OPEN UNIX and except for portions marked with the UX margin legend), and except for those functions listed as residing in math.h. This operand is not required to be present to cause a search of this library. If the implementation defines _XOPEN_UNIX and if the application defines the _XOPEN_SOURCE_EXTENDED feature test macro, then -l c also makes visible all library functions referenced in the XSH specification and labelled X/OPEN UNIX, and portions marked with the UX margin legend, except for those functions listed as residing in math.h.

-l m
This operand makes visible all functions referenced in math.h. An implementation may search this library in the absence of this operand.

-l l
This operand makes visible all functions required by the C-language output of lex(C) that are not made available through the l c operand.

-l y
This operand makes visible all functions required by the C-language output of yacc(C) that are not made available through the -l c operand. In the absence of options that inhibit invocation of the link editor, such as -c or -E, the c89 utility will cause the equivalent of a -l c operand to be passed to the link editor as the last -l operand, causing it to be searched after all other object files and libraries are loaded. It is unspecified whether the libraries libc.a, libm.a, libl.a, or liby.a exist as regular files. The implementation may accept as -l operands names of objects that do not exist as regular files. An application that uses any API specified as X/OPEN UNIX or relies on any portion of an X/Open specification marked with the UX margin legend must define _XOPEN_SOURCE_EXTENDED=1 in each source file or as part of its compilation environment. When _XOPEN_SOURCE_EXTENDED=1 is defined in a source file, it must appear before any header is included.

External symbols

The C compiler and link editor support the significance of external symbols up to a length of at least 31 bytes; the action taken upon encountering symbols exceeding the implementation-dependent maximum symbol length is unspecified. The compiler and link editor support a minimum of 511 external symbols per source or object file, and a minimum of 4095 external symbols in total. A diagnostic message will be written to the standard output if the implementation-dependent limit is exceeded; other actions are unspecified.

Flags

The -l library operands have the format of options, but their position within a list of operands affects the order in which libraries are searched.

The order of specifying the -I and -L options is significant.

The following options are supported:


-c
Suppress the link-edit phase of the compilation, and do not remove any object files that are produced.

-g
Produce symbolic information in the object or executable files; the nature of this information is unspecified, and may be modified by implementation-dependent interactions with other options.

-s
Produce object or executable files, or both, from which symbolic and other information not required for proper execution using the XSH specification exec family has been removed (stripped). If both -g and -s options are present, the action taken is unspecified.

-o outfile
Use the pathname outfile, instead of the default a.out, for the executable file produced. If the -o option is present with -c or -E, the result is unspecified.

-D name[=value]
Define name as if by a C-language #define directive. If no =value operand is given, a value of 1 is used. The -D option has lower precedence than the -U option. That is, if name is used in both a -U and a -D option, name will be undefined regardless of the order of the options. Additional implementation-dependent names may be provided by the compiler. Implementations support at least 2048 bytes of -D definitions and 256 name arguments.

-E
Copy C-language source files to standard output, expanding all preprocessor directives; no compilation will be performed. If any operand is not a text file, the effects are unspecified.

-I directory
Change the algorithm for searching for headers whose names are not absolute pathnames to look in the directory named by the directory pathname before looking in the usual places. Thus, headers whose names are enclosed in double-quotes ("") will be searched for first in the directory of the file with the #include line, then in directories named in -I options, and last in the usual places. For headers whose names are enclosed in angle brackets (<>), the header will be searched for only in directories named in -I options and then in the usual places. Directories named in -I options will be searched in the order specified. Implementations support at least ten instances of this option in a single c89 command invocation.

-L directory
Change the algorithm of searching for the libraries named in the -l objects to look in the directory named by the directory pathname before looking in the usual places. Directories named in -L options will be searched in the order specified. Implementations support at least ten instances of this option in a single c89 command invocation. If a directory specified by a -L option contains files named libc.a, libm.a, libl.a, or liby.a, the results are unspecified.

-O
Optimise. The nature of the optimisation is unspecified.

-U name
Remove any initial definition of name.

Multiple instances of the -D, -I, -L, -U options can be specified.

Operands

An operand is either in the form of a pathname or the form -l library. At least one operand of the pathname form must be specified. The following operands are supported:

file.c
A C-language source file to be compiled and optionally linked. The operand must be of this form if the -c option is used.

file.a
A library of object files typically produced by the ar utility, and passed directly to the link editor. Implementations may recognize implementation-dependent suffixes other than .a as denoting object file libraries.

file.o
An object file produced by c89 and passed directly to the link editor. Implementations may recognize implementation-dependent suffixes other than .o as denoting object files. The processing of other files is implementation-dependent.

-l library
Search the library named:

liblibrary.a

A library will be searched when its name is encountered, so the placement of a -l operand is significant. Several standard libraries can be specified in this manner. Implementations may recognize implementation-dependent suffixes other than .a as denoting libraries.

Input

The input file must be one of the following:

Implementations may supply additional utilities that produce files in these formats. Additional input file formats are implementation-dependent.

Files

Object files or executable files or both are produced in unspecified formats.

Environment variables

The following environment variables affect the execution of c89:

LANG
Provide a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-specific default locale will be used. If any of the internationalization variables contains an invalid setting, the utility will behave as if none of the variables had been defined.

LC_ALL
If set to a non-empty string value, override the values of all the other internationalization variables.

LC_CTYPE
Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments).

LC_MESSAGES
Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.

TMPDIR
Provide a pathname that will override the default directory for temporary files, if any.

Output

If more than one file operand ending in .c (or possibly other unspecified suffixes) is given, its name is written to the standard output. These messages, if written, will precede the processing of each input file; they will not be written to the standard output if they are written to the standard error, as described in ``Diagnostics''.

If the -E option is specified, the standard output will be a text file that represents the results of the preprocessing stage of the language; it may contain extra information appropriate for subsequent compilation passes.

Exit codes

An exit code of 0 indicates successful compilation or link edit. An exit code greater than 0 indicates that an error occurred.

Diagnostics

When c89 encounters a compilation error that causes an object file not to be created, it will write a diagnostic to standard error and continue to compile other source code operands, but it will not perform the link phase and will return a non-zero exit status. If the link edit is unsuccessful, a diagnostic message will be written to standard error and c89 will exit with a non-zero status. A portable application must rely on the exit status of c89, rather than on the existence or mode of the executable file.

If more than one file operand ending in .c (or possibly other unspecified suffixes) is given, the name of the file is written to standard error to allow identification of the diagnostic and warning messages with the appropriate input file. These messages, if written, will precede the processing of each input file; they will not be written to the standard error if they are written to the standard output, as described in ``Output''.

This utility may produce warning messages about certain conditions that do not warrant returning an error (non-zero) exit value.

Usage

Since the c89 utility usually creates files in the current directory during the compilation process, it is typically necessary to run it in a directory in which a file can be created. On systems conforming to the ISO/IEC 9945-2:1993 standard, c89 may be provided only as part of the C-Language Development Option; systems always provide c89.

Some historical implementations have created .o files when -c is not specified and more than one source file is given. Since this area is left unspecified, the application cannot rely on .o files being created, but it also must be prepared for any related .o files that already exist being deleted at the completion of the link edit.

Some historical implementations have permitted -L options to be interspersed with -l operands on the command line. For an application to compile consistently on systems that do not behave like this, it is necessary for a portable application to supply all -L options before any of the -l options.

There is the possible implication that if a user supplies versions of the standard library functions (before they would be encountered by an implicit -l c or explicit -l m), that those versions would be used in place of the standard versions. There are various reasons this might not be true (functions defined as macros, manipulations for clean name space, and so forth), so the existence of files named in the same manner as the standard libraries within the -L directories is explicitly stated to produce unspecified behavior. An application strictly portable to the ISO/IEC 9945-2: 1993 standard cannot rely on TMPDIR overriding the default temporary directory. On XSI-conformant systems, however, this will always be the case.

Examples

The following are examples of usage:

c89 -o foo foo.c

Compiles foo.c and creates the executable file foo.

c89 -c foo.c

Compiles foo.c and creates the object file foo.o.

c89 foo.c

Compiles foo.c and creates the executable file a.out.

c89 foo.c bar.o

Compiles foo.c, links it with bar.o, and creates the executable file a.out. Also creates and leaves foo.o.

The following examples clarify the use and interactions of -L options and -l operands. Consider the case in which module a.c calls function f in library libQ.a, and module b.c calls function g in library libp.a. Assume that both libraries reside in /a/b/c. The command line to compile and link in the desired way is:

c89 -L /a/b/c main.o a.c -l Q b.c -l p

In this case the -l Q operand need only precede the first -l p operand, since both libQ.a and libp.a reside in the same directory.

Multiple -L operands can be used when library name collisions occur. Building on the previous example, suppose that the user wants to use a new libp.a, in /a/a/a, but still wants f from /a/b/c/libQ.a:

c89 -L /a/a/a -L /a/b/c main.o a.c -l Q b.c -l p

In this example, the linker searches the -L options in the order specified, and finds /a/a/a/libp.a before /a/b/c/libp.a when resolving references for b.c. The order of the -l operands is still important, however.

References

ar(C), cc(C), nm(C), strip(C), umask(C).

Notices

Portable applications must specify each option separately; that is, grouping option letters (for example, cO) need not be recognized by all implementations. Also, see ``Diagnostics''.

The -l c operand in the ``Standard Libraries'' section describes access to traditional interfaces if _XOPEN_UNIX is defined.


© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005