компилировать стандартные программы на C (compile standard C programs)
Расширенное описание (Extended description)
Standard Libraries
The c99 utility shall recognize the following -l
options for
standard libraries:
-l c
This option shall make available all interfaces
referenced in the System Interfaces volume of
POSIX.1‐2017, with the possible exception of those
interfaces listed as residing in <aio.h>,
<arpa/inet.h>, <complex.h>, <fenv.h>, <math.h>,
<mqueue.h>, <netdb.h>, <net/if.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>, interfaces marked as optional
in <sys/mman.h>, interfaces marked as ADV (Advisory
Information) in <fcntl.h>, and interfaces beginning
with the prefix clock_ or timer_ in <time.h>. This
option shall not be required to be present to cause a
search of this library.
-l l
This option shall make available all interfaces
required by the C-language output of lex that are not
made available through the -l c
option.
-l pthread
This option shall make available all interfaces
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 option.
-l m
This option shall make available all interfaces
referenced in <math.h>, <complex.h>, and <fenv.h>. An
implementation may search this library in the absence
of this option.
-l rt
This option shall make available all interfaces
referenced in <aio.h>, <mqueue.h>, <sched.h>,
<semaphore.h>, and <spawn.h>, interfaces marked as
optional in <sys/mman.h>, interfaces marked as ADV
(Advisory Information) in <fcntl.h>, and interfaces
beginning with the prefix clock_ and timer_ in
<time.h>. An implementation may search this library in
the absence of this option.
-l trace
This option shall make available all interfaces
referenced in <trace.h>. An implementation may search
this library in the absence of this option.
-l xnet
This option shall make available all interfaces
referenced in <arpa/inet.h>, <netdb.h>, <net/if.h>,
<netinet/in.h>, and <sys/socket.h>. An implementation
may search this library in the absence of this option.
-l y
This option shall make available all interfaces
required by the C-language output of yacc that are not
made available through the -l c
option.
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
option to be passed to the link editor after
the last pathname operand or -l
option, causing it to be searched
after all other object files and libraries are loaded.
It is unspecified whether the libraries libc.a
, libl.a
, libm.a
,
libpthread.a
, librt.a
, libtrace.a
, libxnet.a
, or liby.a
exist as
regular files. The implementation may accept as -l
option-
arguments 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.
Header Search
If a file with the same name as one of the standard headers
defined in the Base Definitions volume of POSIX.1‐2017, Chapter
13, Headers, not provided as part of the implementation, is
placed in any of the usual places that are searched by default
for headers, the results 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 4-4: Programming Environments: Type Sizes
┌────────────────────────┬─────────┬─────────┬─────────┬─────────┐
│Programming Environment
│ Bits in
│ Bits in
│ Bits in
│ Bits in
│
│ getconf Name
│ int
│ long
│ pointer
│ off_t
│
├────────────────────────┼─────────┼─────────┼─────────┼─────────┤
│_POSIX_V7_ILP32_OFF32 │ 32 │ 32 │ 32 │ 32 │
│_POSIX_V7_ILP32_OFFBIG │ 32 │ 32 │ 32 │ ≥64 │
│_POSIX_V7_LP64_OFF64 │ 32 │ 64 │ 64 │ 64 │
│_POSIX_V7_LPBIG_OFFBIG │ ≥32 │ ≥64 │ ≥64 │ ≥64 │
└────────────────────────┴─────────┴─────────┴─────────┴─────────┘
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 ptrdiff_t tcflag_t
cc_t size_t wchar_t
mode_t speed_t wint_t
nfds_t ssize_t
pid_t suseconds_t
The executable files created when these environments are selected
shall be in a proper format for execution by the exec family of
functions. Each environment may be one of the ones in Table 4-4,
Programming Environments: Type Sizes, or it may be another
environment. The names for the environments that meet this
requirement shall be output by a getconf command using the
POSIX_V7_WIDTH_RESTRICTED_ENVS argument, as a <newline>-separated
list of names suitable for use with the getconf -v
option. If
more than one environment meets the requirement, the names of all
such environments shall be output on separate lines. Any of these
names can then be used in a subsequent getconf command to obtain
the flags specific to that environment with the following
suffixes added as appropriate:
_CFLAGS To get the C compiler flags.
_LDFLAGS To get the linker/loader flags.
_LIBS To get the libraries.
This requirement may be removed in a future version.
When this utility processes a file containing a function called
main(), it shall be defined with a return type equivalent to int
.
Using return from the initial call to main() shall be equivalent
(other than with respect to language scope issues) to calling
exit() with the returned value. Reaching the end of the initial
call to main() shall be equivalent to calling exit
(0). The
implementation shall not declare a prototype for this function.
Implementations provide configuration strings for C compiler
flags, linker/loader flags, and libraries for each supported
environment. When an application needs to use a specific
programming environment rather than the implementation default
programming environment while compiling, the application shall
first verify that the implementation supports the desired
environment. If the desired programming environment is supported,
the application shall then invoke c99 with the appropriate C
compiler flags as the first options for the compile, the
appropriate linker/loader flags after any other options except -l
but before any operands or -l
options, and the appropriate
libraries at the end of the operands and -l
options.
Conforming applications shall not attempt to link together object
files compiled for different programming models. Applications
shall also be aware that binary data placed in shared memory or
in files might not be recognized by applications built for other
programming models.
Table 4-5: Programming Environments:
c99 Arguments
┌────────────────────────┬─────────────────────┬───────────────────────────────┐
│Programming Environment
│ │ c99 Arguments
│
│ getconf Name
│ Use
│ getconf Name
│
├────────────────────────┼─────────────────────┼───────────────────────────────┤
│_POSIX_V7_ILP32_OFF32 │ C Compiler Flags │ POSIX_V7_ILP32_OFF32_CFLAGS │
│ │ Linker/Loader Flags │ POSIX_V7_ILP32_OFF32_LDFLAGS │
│ │ Libraries │ POSIX_V7_ILP32_OFF32_LIBS │
├────────────────────────┼─────────────────────┼───────────────────────────────┤
│_POSIX_V7_ILP32_OFFBIG │ C Compiler Flags │ POSIX_V7_ILP32_OFFBIG_CFLAGS │
│ │ Linker/Loader Flags │ POSIX_V7_ILP32_OFFBIG_LDFLAGS │
│ │ Libraries │ POSIX_V7_ILP32_OFFBIG_LIBS │
├────────────────────────┼─────────────────────┼───────────────────────────────┤
│_POSIX_V7_LP64_OFF64 │ C Compiler Flags │ POSIX_V7_LP64_OFF64_CFLAGS │
│ │ Linker/Loader Flags │ POSIX_V7_LP64_OFF64_LDFLAGS │
│ │ Libraries │ POSIX_V7_LP64_OFF64_LIBS │
├────────────────────────┼─────────────────────┼───────────────────────────────┤
│_POSIX_V7_LPBIG_OFFBIG │ C Compiler Flags │ POSIX_V7_LPBIG_OFFBIG_CFLAGS │
│ │ Linker/Loader Flags │ POSIX_V7_LPBIG_OFFBIG_LDFLAGS │
│ │ Libraries │ POSIX_V7_LPBIG_OFFBIG_LIBS │
└────────────────────────┴─────────────────────┴───────────────────────────────┘
In addition to the type size programming environments above, all
implementations also support a multi-threaded programming
environment that is orthogonal to all of the programming
environments listed above. The getconf utility can be used to
get flags for the threaded programming environment, as indicated
in Table 4-6, Threaded Programming Environment: c99 Arguments.
Table 4-6: Threaded Programming Environment:
c99 Arguments
┌────────────────────────┬─────────────────────┬──────────────────────────┐
│Programming Environment
│ │ c99 Arguments
│
│ getconf Name
│ Use
│ getconf Name
│
├────────────────────────┼─────────────────────┼──────────────────────────┤
│_POSIX_THREADS │ C Compiler Flags │ POSIX_V7_THREADS_CFLAGS │
│ │ Linker/Loader Flags │ POSIX_V7_THREADS_LDFLAGS │
└────────────────────────┴─────────────────────┴──────────────────────────┘
These programming environment flags may be used in conjunction
with any of the type size programming environments supported by
the implementation.