1C99(1P)                    POSIX Programmer's Manual                   C99(1P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       c99 — compile standard C programs
14

SYNOPSIS

16       c99 [options...] pathname [[pathname] [−I directory]
17           [−L directory] [−l library]]...
18

DESCRIPTION

20       The c99 utility is an interface to the standard C  compilation  system;
21       it  shall accept source code conforming to the ISO C standard. The sys‐
22       tem conceptually consists of a compiler  and  link  editor.  The  input
23       files  referenced by pathname operands and −l option-arguments shall be
24       compiled and linked to produce an executable file. (It  is  unspecified
25       whether  the  linking occurs entirely within the operation of c99; some
26       implementations may produce objects that are not fully  resolved  until
27       the file is executed.)
28
29       If  the  −c  option is specified, for all pathname operands of the form
30       file.c, the files:
31
32           $(basename pathname .c).o
33
34       shall be created as the result of successful  compilation.  If  the  −c
35       option  is  not  specified, it is unspecified whether such .o files are
36       created or deleted for the file.c operands.
37
38       If there are no options that prevent link editing (such as −c  or  −E),
39       and  all input files compile and link without error, the resulting exe‐
40       cutable file shall be written according to the −o  outfile  option  (if
41       present) or to the file a.out.
42
43       The  executable  file shall be created as specified in Section 1.1.1.4,
44       File Read, Write, and Creation, except that the  file  permission  bits
45       shall be set to: S_IRWXO | S_IRWXG | S_IRWXU
46
47       and the bits specified by the umask of the process shall be cleared.
48

OPTIONS

50       The  c99  utility  shall  conform  to  the  Base  Definitions volume of
51       POSIX.1‐2008, Section 12.2, Utility Syntax Guidelines, except that:
52
53        *  Options can be interspersed with operands.
54
55        *  The order of specifying the −L and −l options,  and  the  order  of
56           specifying −l options with respect to pathname operands is signifi‐
57           cant.
58
59        *  Conforming applications shall specify each option separately;  that
60           is,  grouping  option letters (for example, −cO) need not be recog‐
61           nized by all implementations.
62
63       The following options shall be supported:
64
65       −c        Suppress the link-edit phase of the compilation, and  do  not
66                 remove any object files that are produced.
67
68       −D name[=value]
69                 Define  name  as  if by a C-language #define directive. If no
70                 =value is given, a value of 1 shall be used.  The  −D  option
71                 has  lower precedence than the −U option. That is, if name is
72                 used in both a −U and a −D option, name  shall  be  undefined
73                 regardless  of the order of the options. Additional implemen‐
74                 tation-defined names may be provided by the compiler.  Imple‐
75                 mentations  shall  support  at least 2048 bytes of −D defini‐
76                 tions and 256 names.
77
78       −E        Copy C-language source files to  standard  output,  expanding
79                 all  preprocessor  directives;  no  compilation shall be per‐
80                 formed. If any operand is not a text file,  the  effects  are
81                 unspecified.
82
83       −g        Produce  symbolic  information  in  the  object or executable
84                 files; the nature of this information is unspecified, and may
85                 be modified by implementation-defined interactions with other
86                 options.
87
88       −I directory
89                 Change the algorithm for searching for  headers  whose  names
90                 are  not absolute pathnames to look in the directory named by
91                 the directory pathname before looking in  the  usual  places.
92                 Thus,  headers whose names are enclosed in double-quotes ("")
93                 shall be searched for first in the directory of the file with
94                 the  #include  line, then in directories named in −I options,
95                 and last in the usual places. For  headers  whose  names  are
96                 enclosed  in  angle  brackets  ("<>"),  the  header  shall be
97                 searched for only in directories named in −I options and then
98                 in the usual places. Directories named in −I options shall be
99                 searched in the order specified. If the −I option is used  to
100                 specify  a directory that is one of the usual places searched
101                 by default,  the  results  are  unspecified.  Implementations
102                 shall support at least ten instances of this option in a sin‐
103                 gle c99 command invocation.
104
105       −L directory
106                 Change the algorithm of searching for the libraries named  in
107                 the  −l  objects to look in the directory named by the direc‐
108                 tory pathname before looking in the usual places. Directories
109                 named in −L options shall be searched in the order specified.
110                 If the −L option is used to specify a directory that  is  one
111                 of  the  usual  places  searched  by default, the results are
112                 unspecified.  Implementations  shall  support  at  least  ten
113                 instances  of this option in a single c99 command invocation.
114                 If a directory specified by a −L option contains  files  with
115                 names  starting  with  any  of  the strings "libc.", "libl.",
116                 "libpthread.", "libm.", "librt.", "libtrace.", "libxnet.", or
117                 "liby.", the results are unspecified.
118
119       −l library
120                 Search  the  library  named liblibrary.a.  A library shall be
121                 searched when its name is encountered, so the placement of  a
122                 −l  option  is significant. Several standard libraries can be
123                 specified in  this  manner,  as  described  in  the  EXTENDED
124                 DESCRIPTION  section. Implementations may recognize implemen‐
125                 tation-defined suffixes other than .a as denoting libraries.
126
127       −O optlevel
128                 Specify the level  of  code  optimization.  If  the  optlevel
129                 option-argument  is the digit '0', all special code optimiza‐
130                 tions shall be disabled. If it is the digit '1',  the  nature
131                 of the optimization is unspecified. If the −O option is omit‐
132                 ted, the nature  of  the  system's  default  optimization  is
133                 unspecified.  It is unspecified whether code generated in the
134                 presence of the −O 0 option is the  same  as  that  generated
135                 when −O is omitted. Other optlevel values may be supported.
136
137       −o outfile
138                 Use  the  pathname outfile, instead of the default a.out, for
139                 the executable file produced. If the  −o  option  is  present
140                 with −c or −E, the result is unspecified.
141
142       −s        Produce  object or executable files, or both, from which sym‐
143                 bolic and other information not required for proper execution
144                 using the exec family defined in the System Interfaces volume
145                 of POSIX.1‐2008 has been removed (stripped). If both  −g  and
146                 −s options are present, the action taken is unspecified.
147
148       −U name   Remove any initial definition of name.
149
150       Multiple  instances of the −D, −I, −L, −l, and −U options can be speci‐
151       fied.
152

OPERANDS

154       The application shall ensure that at  least  one  pathname  operand  is
155       specified.  The  following  forms  for  pathname operands shall be sup‐
156       ported:
157
158       file.c    A C-language  source  file  to  be  compiled  and  optionally
159                 linked.  The  application shall ensure that the operand is of
160                 this form if the −c option is used.
161
162       file.a    A library of object files typically produced by the ar  util‐
163                 ity,  and passed directly to the link editor. Implementations
164                 may recognize implementation-defined suffixes other  than  .a
165                 as denoting object file libraries.
166
167       file.o    An  object file produced by c99 −c and passed directly to the
168                 link editor. Implementations  may  recognize  implementation-
169                 defined suffixes other than .o as denoting object files.
170
171       The processing of other files is implementation-defined.
172

STDIN

174       Not used.
175

INPUT FILES

177       Each input file shall be one of the following: a text file containing a
178       C-language source program, an object file in the format produced by c99
179       −c,  or  a library of object files, in the format produced by archiving
180       zero or more object files, using ar.  Implementations may supply  addi‐
181       tional  utilities that produce files in these formats. Additional input
182       file formats are implementation-defined.
183

ENVIRONMENT VARIABLES

185       The following environment variables shall affect the execution of c99:
186
187       LANG      Provide a default value for  the  internationalization  vari‐
188                 ables  that are unset or null. (See the Base Definitions vol‐
189                 ume of POSIX.1‐2008, Section 8.2, Internationalization  Vari‐
190                 ables  for  the  precedence of internationalization variables
191                 used to determine the values of locale categories.)
192
193       LC_ALL    If set to a non-empty string value, override  the  values  of
194                 all the other internationalization variables.
195
196       LC_CTYPE  Determine  the  locale for the interpretation of sequences of
197                 bytes of text data as characters (for example, single-byte as
198                 opposed  to  multi-byte  characters  in  arguments  and input
199                 files).
200
201       LC_MESSAGES
202                 Determine the locale that should be used to affect the format
203                 and  contents  of  diagnostic  messages  written  to standard
204                 error.
205
206       NLSPATH   Determine the location of message catalogs for the processing
207                 of LC_MESSAGES.
208
209       TMPDIR    Provide a pathname that should override the default directory
210                 for temporary files, if any.  On XSI-conforming systems, pro‐
211                 vide a pathname that shall override the default directory for
212                 temporary files, if any.
213

ASYNCHRONOUS EVENTS

215       Default.
216

STDOUT

218       If more than one pathname operand  ending  in  .c  (or  possibly  other
219       unspecified suffixes) is given, for each such file:
220
221           "%s:\n", <pathname>
222
223       may  be written. These messages, if written, shall precede the process‐
224       ing of each input file; they shall not be written to the standard  out‐
225       put  if  they  are  written  to the standard error, as described in the
226       STDERR section.
227
228       If the −E option is specified, the standard output shall be a text file
229       that represents the results of the preprocessing stage of the language;
230       it may contain extra information appropriate for subsequent compilation
231       passes.
232

STDERR

234       The standard error shall be used only for diagnostic messages.  If more
235       than one pathname operand ending in .c (or possibly  other  unspecified
236       suffixes) is given, for each such file:
237
238           "%s:\n", <pathname>
239
240       may  be  written  to allow identification of the diagnostic and warning
241       messages with the appropriate input file. These messages,  if  written,
242       shall  precede  the  processing  of  each input file; they shall not be
243       written to the standard error if they are written to the standard  out‐
244       put, as described in the STDOUT section.
245
246       This utility may produce warning messages about certain conditions that
247       do not warrant returning an error (non-zero) exit value.
248

OUTPUT FILES

250       Object files or executable files or both are  produced  in  unspecified
251       formats.  If  the  pathname  of an object file or executable file to be
252       created by c99 resolves to an existing directory entry for a file  that
253       is  not  a regular file, it is unspecified whether c99 shall attempt to
254       create the file or shall issue a diagnostic and exit  with  a  non-zero
255       exit status.
256

EXTENDED DESCRIPTION

258   Standard Libraries
259       The  c99  utility shall recognize the following −l options for standard
260       libraries:
261
262       −l c      This option shall make available all interfaces referenced in
263                 the System Interfaces volume of POSIX.1‐2008, with the possi‐
264                 ble exception of  those  interfaces  listed  as  residing  in
265                 <aio.h>,   <arpa/inet.h>,  <complex.h>,  <fenv.h>,  <math.h>,
266                 <mqueue.h>,    <netdb.h>,     <net/if.h>,     <netinet/in.h>,
267                 <pthread.h>,     <sched.h>,     <semaphore.h>,     <spawn.h>,
268                 <sys/socket.h>,  pthread_kill(),  and  pthread_sigmask()   in
269                 <signal.h>,  <trace.h>,  interfaces  marked  as  optional  in
270                 <sys/mman.h>, interfaces marked as ADV (Advisory Information)
271                 in <fcntl.h>, and interfaces beginning with the prefix clock_
272                 or time_ in <time.h>.  This option shall not be  required  to
273                 be present to cause a search of this library.
274
275       −l l      This  option  shall make available all interfaces required by
276                 the C-language output of lex  that  are  not  made  available
277                 through the −l c option.
278
279       −l pthread
280                 This option shall make available all interfaces referenced in
281                 <pthread.h> and pthread_kill() and  pthread_sigmask()  refer‐
282                 enced  in  <signal.h>.   An  implementation  may  search this
283                 library in the absence of this option.
284
285       −l m      This option shall make available all interfaces referenced in
286                 <math.h>,  <complex.h>,  and <fenv.h>.  An implementation may
287                 search this library in the absence of this option.
288
289       −l rt     This option shall make available all interfaces referenced in
290                 <aio.h>, <mqueue.h>, <sched.h>, <semaphore.h>, and <spawn.h>,
291                 interfaces marked as  optional  in  <sys/mman.h>,  interfaces
292                 marked as ADV (Advisory Information) in <fcntl.h>, and inter‐
293                 faces beginning with the prefix clock_ and time_ in <time.h>.
294                 An  implementation  may search this library in the absence of
295                 this option.
296
297       −l trace  This option shall make available all interfaces referenced in
298                 <trace.h>.   An implementation may search this library in the
299                 absence of this option.
300
301       −l xnet   This option shall make available all interfaces referenced in
302                 <arpa/inet.h>,  <netdb.h>,  <net/if.h>,  <netinet/in.h>,  and
303                 <sys/socket.h>.  An implementation may search this library in
304                 the absence of this option.
305
306       −l y      This  option  shall make available all interfaces required by
307                 the C-language output of yacc that  are  not  made  available
308                 through the −l c option.
309
310       In  the  absence of options that inhibit invocation of the link editor,
311       such as −c or −E, the c99 utility shall cause the equivalent of a  −l c
312       option  to be passed to the link editor after the last pathname operand
313       or −l option, causing it to be searched after all  other  object  files
314       and libraries are loaded.
315
316       It  is  unspecified  whether  the  libraries  libc.a,  libl.a,  libm.a,
317       libpthread.a, librt.a, libtrace.a, libxnet.a, or liby.a exist as  regu‐
318       lar  files.  The implementation may accept as −l option-arguments names
319       of objects that do not exist as regular files.
320
321   External Symbols
322       The C compiler and link editor shall support the significance of exter‐
323       nal  symbols up to a length of at least 31 bytes; the action taken upon
324       encountering symbols exceeding the implementation-defined maximum  sym‐
325       bol length is unspecified.
326
327       The  compiler  and  link editor shall support a minimum of 511 external
328       symbols per source or object file, and a minimum of 4095 external  sym‐
329       bols  in  total.  A diagnostic message shall be written to the standard
330       output if the implementation-defined limit is exceeded;  other  actions
331       are unspecified.
332
333   Header Search
334       If  a file with the same name as one of the standard headers defined in
335       the Base Definitions volume of POSIX.1‐2008, Chapter 13,  Headers,  not
336       provided  as  part of the implementation, is placed in any of the usual
337       places that are searched  by  default  for  headers,  the  results  are
338       unspecified.
339
340   Programming Environments
341       All  implementations  shall  support  one  of the following programming
342       environments as a default. Implementations may support more than one of
343       the  following programming environments. Applications can use sysconf()
344       or getconf to determine which programming environments are supported.
345
346                   Table 4-4: Programming Environments: Type Sizes
347
348          ┌────────────────────────┬─────────┬─────────┬─────────┬─────────┐
349Programming Environment Bits in Bits in Bits in Bits in 
350getconf Name       int   long   pointer off_t  
351          ├────────────────────────┼─────────┼─────────┼─────────┼─────────┤
352          │_POSIX_V7_ILP32_OFF32   │    32   │    32   │    32   │    32   │
353          │_POSIX_V7_ILP32_OFFBIG  │    32   │    32   │    32   │   ≥64   │
354          │_POSIX_V7_LP64_OFF64    │    32   │    64   │    64   │    64   │
355          │_POSIX_V7_LPBIG_OFFBIG  │   ≥32   │   ≥64   │   ≥64   │   ≥64   │
356          └────────────────────────┴─────────┴─────────┴─────────┴─────────┘
357       All implementations shall support one or more  environments  where  the
358       widths  of  the  following  types are no greater than the width of type
359       long:
360
361                         blksize_t   ptrdiff_t     tcflag_t
362                         cc_t        size_t        wchar_t
363                         mode_t      speed_t       wint_t
364                         nfds_t      ssize_t
365                         pid_t       suseconds_t
366
367       The executable files created when these environments are selected shall
368       be  in  a  proper format for execution by the exec family of functions.
369       Each environment may be one of the ones in Table 4-4, Programming Envi‐
370       ronments:  Type  Sizes, or it may be another environment. The names for
371       the environments that meet this requirement shall be output by  a  get‐
372       conf  command  using  the POSIX_V7_WIDTH_RESTRICTED_ENVS argument, as a
373       <newline>-separated list of names suitable for use with the getconf  −v
374       option.  If  more than one environment meets the requirement, the names
375       of all such environments shall be output  on  separate  lines.  Any  of
376       these  names can then be used in a subsequent getconf command to obtain
377       the flags specific to that  environment  with  the  following  suffixes
378       added as appropriate:
379
380       _CFLAGS   To get the C compiler flags.
381
382       _LDFLAGS  To get the linker/loader flags.
383
384       _LIBS     To get the libraries.
385
386       This requirement may be removed in a future version.
387
388       When this utility processes a file containing a function called main(),
389       it shall be defined with a return type equivalent to int.  Using return
390       from  the  initial  call to main() shall be equivalent (other than with
391       respect to language scope issues) to calling exit() with  the  returned
392       value.  Reaching the end of the initial call to main() shall be equiva‐
393       lent to calling exit(0).  The implementation shall not declare a proto‐
394       type for this function.
395
396       Implementations  provide  configuration  strings  for C compiler flags,
397       linker/loader flags, and  libraries  for  each  supported  environment.
398       When  an  application  needs  to use a specific programming environment
399       rather than the implementation default  programming  environment  while
400       compiling,  the  application shall first verify that the implementation
401       supports the desired environment. If the desired  programming  environ‐
402       ment  is  supported,  the  application  shall  then invoke c99 with the
403       appropriate C compiler flags as the first options for the compile,  the
404       appropriate  linker/loader  flags after any other options except −l but
405       before any operands or −l options, and the appropriate libraries at the
406       end of the operands and −l options.
407
408       Conforming applications shall not attempt to link together object files
409       compiled for different programming models. Applications shall  also  be
410       aware that binary data placed in shared memory or in files might not be
411       recognized by applications built for other programming models.
412
413                 Table 4-5: Programming Environments: c99 Arguments
414
415   ┌────────────────────────┬─────────────────────┬───────────────────────────────┐
416Programming Environment │                     │         c99 Arguments         
417getconf Name       Use         getconf Name          
418   ├────────────────────────┼─────────────────────┼───────────────────────────────┤
419   │_POSIX_V7_ILP32_OFF32   │ C Compiler Flags    │ POSIX_V7_ILP32_OFF32_CFLAGS   │
420   │                        │ Linker/Loader Flags │ POSIX_V7_ILP32_OFF32_LDFLAGS  │
421   │                        │ Libraries           │ POSIX_V7_ILP32_OFF32_LIBS     │
422   ├────────────────────────┼─────────────────────┼───────────────────────────────┤
423   │_POSIX_V7_ILP32_OFFBIG  │ C Compiler Flags    │ POSIX_V7_ILP32_OFFBIG_CFLAGS  │
424   │                        │ Linker/Loader Flags │ POSIX_V7_ILP32_OFFBIG_LDFLAGS │
425   │                        │ Libraries           │ POSIX_V7_ILP32_OFFBIG_LIBS    │
426   ├────────────────────────┼─────────────────────┼───────────────────────────────┤
427   │_POSIX_V7_LP64_OFF64    │ C Compiler Flags    │ POSIX_V7_LP64_OFF64_CFLAGS    │
428   │                        │ Linker/Loader Flags │ POSIX_V7_LP64_OFF64_LDFLAGS   │
429   │                        │ Libraries           │ POSIX_V7_LP64_OFF64_LIBS      │
430   ├────────────────────────┼─────────────────────┼───────────────────────────────┤
431   │_POSIX_V7_LPBIG_OFFBIG  │ C Compiler Flags    │ POSIX_V7_LPBIG_OFFBIG_CFLAGS  │
432   │                        │ Linker/Loader Flags │ POSIX_V7_LPBIG_OFFBIG_LDFLAGS │
433   │                        │ Libraries           │ POSIX_V7_LPBIG_OFFBIG_LIBS    │
434   └────────────────────────┴─────────────────────┴───────────────────────────────┘
435       In addition to the type size programming environments above, all imple‐
436       mentations  also  support a multi-threaded programming environment that
437       is orthogonal to all of the programming environments listed above.  The
438       getconf  utility  can be used to get flags for the threaded programming
439       environment, as indicated in Table 4-6, Threaded  Programming  Environ‐
440       ment: c99 Arguments.
441
442             Table 4-6: Threaded Programming Environment: c99 Arguments
443
444      ┌────────────────────────┬─────────────────────┬──────────────────────────┐
445Programming Environment │                     │      c99 Arguments       
446getconf Name       Use         getconf Name       
447      ├────────────────────────┼─────────────────────┼──────────────────────────┤
448      │_POSIX_THREADS          │ C Compiler Flags    │ POSIX_V7_THREADS_CFLAGS  │
449      │                        │ Linker/Loader Flags │ POSIX_V7_THREADS_LDFLAGS │
450      └────────────────────────┴─────────────────────┴──────────────────────────┘
451       These programming environment flags may be used in conjunction with any
452       of the type size programming environments supported by the  implementa‐
453       tion.
454

EXIT STATUS

456       The following exit values shall be returned:
457
458        0    Successful compilation or link edit.
459
460       >0    An error occurred.
461

CONSEQUENCES OF ERRORS

463       When  c99 encounters a compilation error that causes an object file not
464       to be created, it shall write a diagnostic to standard error  and  con‐
465       tinue  to  compile other source code operands, but it shall not perform
466       the link phase and return a non-zero exit status. If the link  edit  is
467       unsuccessful,  a  diagnostic message shall be written to standard error
468       and c99 exits with a non-zero status. A  conforming  application  shall
469       rely on the exit status of c99, rather than on the existence or mode of
470       the executable file.
471
472       The following sections are informative.
473

APPLICATION USAGE

475       Since the c99 utility usually creates files in  the  current  directory
476       during  the  compilation  process, it is typically necessary to run the
477       c99 utility in a directory in which a file can be created.
478
479       On systems providing POSIX Conformance (see the Base Definitions volume
480       of POSIX.1‐2008, Chapter 2, Conformance), c99 is required only with the
481       C-Language Development option; XSI-conformant  systems  always  provide
482       c99.
483
484       Some  historical  implementations  have created .o files when −c is not
485       specified and more than one source file is given. Since  this  area  is
486       left  unspecified,  the  application cannot rely on .o files being cre‐
487       ated, but it also must be  prepared  for  any  related  .o  files  that
488       already exist being deleted at the completion of the link edit.
489
490       There  is  the possible implication that if a user supplies versions of
491       the standard functions (before they would be encountered by an implicit
492       −l c  or  explicit −l m), that those versions would be used in place of
493       the standard versions.  There are various reasons  this  might  not  be
494       true  (functions defined as macros, manipulations for clean name space,
495       and so on), so the existence of files named in the same manner  as  the
496       standard  libraries  within  the −L directories is explicitly stated to
497       produce unspecified behavior.
498
499       All of the functions specified  in  the  System  Interfaces  volume  of
500       POSIX.1‐2008 may be made visible by implementations when the Standard C
501       Library is searched. Conforming applications  must  explicitly  request
502       searching  the  other standard libraries when functions made visible by
503       those libraries are used.
504
505       In the ISO C standard the mapping from physical  source  characters  to
506       the  C  source character set is implementation-defined. Implementations
507       may strip white-space characters before the terminating <newline> of  a
508       (physical)  line as part of this mapping and, as a consequence of this,
509       one or more white-space characters (and no other characters) between  a
510       <backslash>  character  and the <newline> character that terminates the
511       line produces  implementation-defined  results.  Portable  applications
512       should not use such constructs.
513
514       Some  c99  compilers not conforming to POSIX.1‐2008 do not support tri‐
515       graphs by default.
516

EXAMPLES

518        1. The following usage example compiles foo.c  and  creates  the  exe‐
519           cutable file foo:
520
521               c99 −o foo foo.c
522
523           The  following  usage example compiles foo.c and creates the object
524           file foo.o:
525
526               c99 −c foo.c
527
528           The following usage example compiles foo.c  and  creates  the  exe‐
529           cutable file a.out:
530
531               c99 foo.c
532
533           The  following  usage  example compiles foo.c, links it with bar.o,
534           and creates the executable file a.out.   It  may  also  create  and
535           leave foo.o:
536
537               c99 foo.c bar.o
538
539        2. The following example shows how an application using threads inter‐
540           faces can test for support of and  use  a  programming  environment
541           supporting  32-bit  int,  long, and pointer types and an off_t type
542           using at least 64 bits:
543
544               offbig_env=$(getconf _POSIX_V7_ILP32_OFFBIG)
545               if [ $offbig_env != "-1" ] && [ $offbig_env != "undefined" ]
546               then
547                   c99 $(getconf POSIX_V7_ILP32_OFFBIG_CFLAGS) \
548                   $(getconf POSIX_V7_THREADS_CFLAGS) -D_XOPEN_SOURCE=700 \
549                   $(getconf POSIX_V7_ILP32_OFFBIG_LDFLAGS) \
550                   $(getconf POSIX_V7_THREADS_LDFLAGS) foo.c -o foo \
551                   $(getconf POSIX_V7_ILP32_OFFBIG_LIBS) \
552                   -l pthread
553               else
554                   echo ILP32_OFFBIG programming environment not supported
555                   exit 1
556               fi
557
558        3. The following examples clarify the use and interactions of  −L  and
559           −l options.
560
561           Consider the case in which module a.c calls function f() in library
562           libQ.a, and module  b.c  calls  function  g()  in  library  libp.a.
563           Assume  that  both libraries reside in /a/b/c.  The command line to
564           compile and link in the desired way is:
565
566               c99 −L /a/b/c main.o a.c −l Q b.c −l p
567
568           In this case the −L option need only precede the first  −l  option,
569           since both libQ.a and libp.a reside in the same directory.
570
571           Multiple −L options can be used when library name collisions occur.
572           Building on the previous example, suppose that the  user  wants  to
573           use   a   new   libp.a,   in  /a/a/a,  but  still  wants  f()  from
574           /a/b/c/libQ.a:
575
576               c99 −L /a/a/a −L /a/b/c main.o a.c −l Q b.c −l p
577
578           In this example, the linker searches the −L options  in  the  order
579           specified,   and  finds  /a/a/a/libp.a  before  /a/b/c/libp.a  when
580           resolving references for b.c.  The order of the −l options is still
581           important, however.
582
583        4. The  following  example shows how an application can use a program‐
584           ming environment where the widths  of  the  following  types:  blk‐
585           size_t,  cc_t,  mode_t,  nfds_t, pid_t, ptrdiff_t, size_t, speed_t,
586           ssize_t, suseconds_t, tcflag_t, wchar_t, wint_t
587
588           are no greater than the width of type long:
589
590               # First choose one of the listed environments ...
591
592               # ... if there are no additional constraints, the first one will do:
593               CENV=$(getconf POSIX_V7_WIDTH_RESTRICTED_ENVS | head -n l)
594
595               # ... or, if an environment that supports large files is preferred,
596               # look for names that contain "OFF64" or "OFFBIG". (This chooses
597               # the last one in the list if none match.)
598               for CENV in $(getconf POSIX_V7_WIDTH_RESTRICTED_ENVS)
599               do
600                   case $CENV in
601                   *OFF64*|*OFFBIG*) break ;;
602                   esac
603               done
604
605               # The chosen environment name can now be used like this:
606
607               c99 $(getconf ${CENV}_CFLAGS) -D _POSIX_C_SOURCE=200809L \
608               $(getconf ${CENV}_LDFLAGS) foo.c -o foo \
609               $(getconf ${CENV}_LIBS)
610

RATIONALE

612       The c99 utility is based on the c89 utility  originally  introduced  in
613       the ISO POSIX‐2:1993 standard.
614
615       Some of the changes from c89 include the ability to intersperse options
616       and operands (which many c89 implementations  allowed  despite  it  not
617       being  specified), the description of −l as an option instead of an op‐
618       erand, and the modification to the contents of the  Standard  Libraries
619       section  to account for new headers and options; for example, <spawn.h>
620       added to the description of −l rt, and −l trace added for  the  Tracing
621       option.
622
623       POSIX.1‐2008 specifies that the c99 utility must be able to use regular
624       files for *.o files and for a.out files. Implementations  are  free  to
625       overwrite  existing  files  of  other  types  when attempting to create
626       object files and executable files, but are not required to  do  so.  If
627       something other than a regular file is specified and using it fails for
628       any reason, c99 is required to issue a diagnostic message and exit with
629       a non-zero exit status. But for some file types, the problem may not be
630       noticed for a long time. For example, if a FIFO named a.out  exists  in
631       the  current  directory, c99 may attempt to open a.out and will hang in
632       the open() call until another process opens the FIFO for reading.  Then
633       c99  may  write most of the a.out to the FIFO and fail when it tries to
634       seek back close to the start of the file to insert a  timestamp  (FIFOs
635       are  not  seekable  files).  The c99 utility is also allowed to issue a
636       diagnostic immediately if it encounters an a.out or *.o  file  that  is
637       not  a  regular file. For portable use, applications should ensure that
638       any a.out, −o option-argument, or *.o files corresponding  to  any  *.c
639       files  do  not  conflict with names already in use that are not regular
640       files or symbolic links that point to regular files.
641
642       On many systems, multi-threaded applications run in a programming envi‐
643       ronment  that  is  distinct  from that used by single-threaded applica‐
644       tions. This multi-threaded  programming  environment  (in  addition  to
645       needing  to  specify  −l  pthread  at link time) may require additional
646       flags to be set when headers are processed at  compile  time  (−D_REEN‐
647       TRANT  being common). This programming environment is orthogonal to the
648       type size programming environments discussed above and listed in  Table
649       4-4,  Programming  Environments: Type Sizes.  This version of the stan‐
650       dard adds getconf utility calls to provide the  C  compiler  flags  and
651       linker/loader flags needed to support multi-threaded applications. Note
652       that on a system where single-threaded applications are a special  case
653       of a multi-threaded application, both of these getconf calls may return
654       NULL strings; on other implementations both of  these  strings  may  be
655       non-NULL strings.
656
657       The C standardization committee invented trigraphs (e.g., "??!" to rep‐
658       resent '|') to address character portability  problems  in  development
659       environments  based  on national variants of the 7-bit ISO/IEC 646:1991
660       standard character set. However, these environments were already  obso‐
661       lete  by  the time the first ISO C standard was published, and in prac‐
662       tice trigraphs have not been used for their intended purpose, and  usu‐
663       ally  are  intended to have their original meaning in K&R C.  For exam‐
664       ple, in practice a C-language source string like "What??!"  is  usually
665       intended  to end in two <question-mark> characters and an <exclamation-
666       mark>, not in '|'.
667

FUTURE DIRECTIONS

669       None.
670

SEE ALSO

672       Section 1.1.1.4, File Read, Write, and Creation, ar, getconf, make, nm,
673       strip, umask
674
675       The  Base  Definitions  volume  of POSIX.1‐2008, Chapter 8, Environment
676       Variables, Section 12.2, Utility Syntax Guidelines, Chapter 13, Headers
677
678       The System Interfaces volume of POSIX.1‐2008, exec, sysconf()
679
681       Portions of this text are reprinted and reproduced in  electronic  form
682       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
683       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
684       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
685       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
686       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
687       event of any discrepancy between this version and the original IEEE and
688       The  Open Group Standard, the original IEEE and The Open Group Standard
689       is the referee document. The original Standard can be  obtained  online
690       at http://www.unix.org/online.html .
691
692       Any  typographical  or  formatting  errors that appear in this page are
693       most likely to have been introduced during the conversion of the source
694       files  to  man page format. To report such errors, see https://www.ker
695       nel.org/doc/man-pages/reporting_bugs.html .
696
697
698
699IEEE/The Open Group                  2013                              C99(1P)
Impressum