c99(1) - Linux man page
Name
c99 - compile standard C programsSynopsis
c99 [-c][-D
name[=value]]...[-E][-g][-I directory] ...
[-L directory]
... [-o
outfile][-Ooptlevel][-s][-U name]... operand ...
Description
The c99 utility is an interface to the standard C compilation system; it shall accept source code conforming to the ISO C standard. The system conceptually consists of a compiler and link editor. The files referenced by operands shall be compiled and linked to produce an executable file. (It is unspecified whether the linking occurs entirely within the operation of c99; some implementations may produce objects that are not fully resolved until the file is executed.)
If the -c option is specified, for all pathname operands of the form file .c, the files:
$(basename pathname .c).o
shall be 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 shall be written according to the -o outfile option (if present) or to the file a.out.
The executable file shall be created as specified in File Read, Write, and Creation , except that the file permission bits shall be set to:
S_IRWXO | S_IRWXG | S_IRWXU
and the bits specified by the umask of the process shall be cleared.
Options
The c99 utility shall conform to the Base Definitions volume of IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines, except that:
- *
- 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.
- *
- Conforming applications shall specify each option separately; that is, grouping option letters (for example, -cO) need not be recognized by all implementations.
The following options shall be 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-defined 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 exec family defined in the System Interfaces volume of IEEE Std 1003.1-2001 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 is given, a value of 1 shall be 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 shall be undefined regardless of the order of the options. Additional implementation-defined names may be provided by the compiler. Implementations shall support at least 2048 bytes of -D definitions and 256 names.
- -E
- Copy C-language source files to standard output, expanding all preprocessor directives; no compilation shall 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 ( "" ) shall 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 shall be searched for only in directories named in -I options and then in the usual places. Directories named in -I options shall be searched in the order specified. Implementations shall support at least ten instances of this option in a single c99 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 shall be searched in the order specified. Implementations shall support at least ten instances of this option in a single c99 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 optlevel
- Specify the level of code optimization. If the optlevel option-argument is the digit '0' , all special code optimizations shall be disabled. If it is the digit '1' , the nature of the optimization is unspecified. If the -O option is omitted, the nature of the system's default optimization is unspecified. It is unspecified whether code generated in the presence of the -O 0 option is the same as that generated when -O is omitted. Other optlevel values may be supported.
- -U name
- Remove any initial definition of name.
Multiple instances of the -D, -I, -U, and -L options can be specified.
Operands
An operand is either in the form of a pathname or the form -l library. The application shall ensure that at least one operand of the pathname form is specified. The following operands shall be supported:
- file.c
- A C-language source file to be compiled and optionally linked. The application shall ensure that the operand is 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-defined suffixes other than .a as denoting object file libraries.
- file.o
- An object file produced by c99 -c and passed directly to the link editor. Implementations may recognize implementation-defined suffixes other than .o as denoting object files.
The processing of other files is implementation-defined.
- -l library
- (The letter ell.) Search the library named:
liblibrary.a
A library shall 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, as described in the EXTENDED DESCRIPTION section. Implementations may recognize implementation-defined suffixes other than .a as denoting libraries.
Stdin
Not used.
Input Files
The input file shall be one of the following: a text file containing a C-language source program, an object file in the format produced by c99 -c, or a library of object files, in the format produced by archiving zero or more object files, using ar. Implementations may supply additional utilities that produce files in these formats. Additional input file formats are implementation-defined.
Environment Variables
The following environment variables shall affect the execution of c99:
- LANG
- Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of IEEE Std 1003.1-2001, Section 8.2, Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.)
- 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-byte as opposed to multi-byte characters in arguments and input files).
- LC_MESSAGES
- Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
- NLSPATH
- Determine the location of message catalogs for the processing of LC_MESSAGES .
- TMPDIR
- Provide a pathname that should override the default directory for temporary files, if any. On XSI-conforming systems, provide a pathname that shall override the default directory for temporary files, if any.
Asynchronous Events
Default.
Stdout
If more than one file operand ending in .c (or possibly other unspecified suffixes) is given, for each such file:
"%s:\n", <file>
may be written. These messages, if written, shall precede the processing of each input file; they shall not be written to the standard output if they are written to the standard error, as described in the STDERR section.
If the -E option is specified, the standard output shall 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.
Stderr
The standard error shall be used only for diagnostic messages. If more than one file operand ending in .c (or possibly other unspecified suffixes) is given, for each such file:
"%s:\n", <file>
may be written to allow identification of the diagnostic and warning messages with the appropriate input file. These messages, if written, shall precede the processing of each input file; they shall not be written to the standard error if they are written to the standard output, as described in the STDOUT section.
This utility may produce warning messages about certain conditions that do not warrant returning an error (non-zero) exit value.
Output Files
Object files or executable files or both are produced in unspecified formats.
Extended Description
Standard Libraries
The c99 utility shall recognize the following -l operands for standard libraries:
- -l c
- This operand shall make visible all functions referenced in the System Interfaces volume of IEEE Std 1003.1-2001, with the possible exception of those functions listed as residing in <aio.h>, <arpa/inet.h>, <complex.h>, <fenv.h>, <math.h>, <mqueue.h>, <netdb.h>, <netinet/in.h>, <pthread.h>, <sched.h>, <semaphore.h>, <spawn.h>, <sys/socket.h>, pthread_kill(), and pthread_sigmask() in <signal.h>, <trace.h>, functions marked as extensions other than as part of the MF or MPR extensions in <sys/mman.h>, functions marked as ADV in <fcntl.h>, and functions marked as CS, CPT, and TMR in <time.h>. This operand shall not be required to be present to cause a search of this library.
- -l l
- This operand shall make visible all functions required by the C-language output of lex that are not made available through the -l c operand.
- -l pthread
- This operand shall make visible all functions referenced in <pthread.h> and pthread_kill() and pthread_sigmask() referenced in <signal.h>. An implementation may search this library in the absence of this operand.
- -l m
- This operand shall make visible all functions referenced in <math.h>, <complex.h>, and <fenv.h>. An implementation may search this library in the absence of this operand.
- -l rt
- This operand shall make visible all functions referenced in <aio.h>, <mqueue.h>, <sched.h>, <semaphore.h>, and <spawn.h>, functions marked as extensions other than as part of the MF or MPR extensions in <sys/mman.h>, functions marked as ADV in <fcntl.h>, and functions marked as CS, CPT, and TMR in <time.h>. An implementation may search this library in the absence of this operand.
- -l trace
- This operand shall make visible all functions referenced in <trace.h>. An implementation may search this library in the absence of this operand.
- -l xnet
- This operand makes visible all functions referenced in <arpa/inet.h>, <netdb.h>, <netinet/in.h>, and <sys/socket.h>. An implementation may search this library in the absence of this operand.
- -l y
- This operand shall make visible all functions required by the C-language output of yacc 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 c99 utility shall 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, librt.a, libpthread.a, libl.a, liby.a, or libxnet.a exist as regular files. The implementation may accept as -l operands names of objects that do not exist as regular files.
External Symbols
The C compiler and link editor shall support the significance of external symbols up to a length of at least 31 bytes; the action taken upon encountering symbols exceeding the implementation-defined maximum symbol length is unspecified.
The compiler and link editor shall support a minimum of 511 external symbols per source or object file, and a minimum of 4095 external symbols in total. A diagnostic message shall be written to the standard output if the implementation-defined limit is exceeded; other actions are unspecified.
Programming Environments
All implementations shall support one of the following programming environments as a default. Implementations may support more than one of the following
programming environments. Applications can use sysconf() or getconf to determine which programming environments are supported.
- Table: Programming Environments: c99 and cc Arguments
-
Exit Status
0Successful compilation or link edit.>0An error occurred.Consequences of Errors
Application Usage
Examples
- 1.
- 2.
- 3.
| All implementations shall support one or more environments where the |
| widths of the following types are no greater than the width |
| of type long: |
| blksize_t, cc_t, mode_t, nfds_t, pid_t, |
| ptrdiff_t, size_t, |
| speed_t, ssize_t, suseconds_t, tcflag_t, useconds_t, |
| The following exit values shall be returned: |
| When c99 encounters a compilation error that causes an object |
| file not to be created, it shall write a diagnostic to |
| standard error and continue to compile other source code operands, |
| but it shall not perform the link phase and return a non-zero |
| exit status. If the link edit is unsuccessful, a diagnostic message |
| shall be written to standard error and c99 exits with a |
| non-zero status. A conforming application shall rely on the exit status |
| of c99, rather than on the existence or mode of the |
| executable file. |
- 4.
