📄 c99.html
字号:
</td><td align="left"><p class="tent">Linker/Loader Flags</p></td><td align="left"><p class="tent">POSIX_V6_ILP32_OFFBIG_LDFLAGS</p></td></tr><tr valign="top"><td align="left"><p class="tent"> </p></td><td align="left"><p class="tent">Libraries</p></td><td align="left"><p class="tent">POSIX_V6_ILP32_OFFBIG_LIBS</p></td></tr><tr valign="top"><td align="left"><p class="tent">_POSIX_V6_LP64_OFF64</p></td><td align="left"><p class="tent">C Compiler Flags</p></td><td align="left"><p class="tent">POSIX_V6_LP64_OFF64_CFLAGS</p></td></tr><tr valign="top"><td align="left"><p class="tent"> </p></td><td align="left"><p class="tent">Linker/Loader Flags</p></td><td align="left"><p class="tent">POSIX_V6_LP64_OFF64_LDFLAGS</p></td></tr><tr valign="top"><td align="left"><p class="tent"> </p></td><td align="left"><p class="tent">Libraries</p></td><td align="left"><p class="tent">POSIX_V6_LP64_OFF64_LIBS</p></td></tr><tr valign="top"><td align="left"><p class="tent">_POSIX_V6_LPBIG_OFFBIG</p></td><td align="left"><p class="tent">C Compiler Flags</p></td><td align="left"><p class="tent">POSIX_V6_LPBIG_OFFBIG_CFLAGS</p></td></tr><tr valign="top"><td align="left"><p class="tent"> </p></td><td align="left"><p class="tent">Linker/Loader Flags</p></td><td align="left"><p class="tent">POSIX_V6_LPBIG_OFFBIG_LDFLAGS</p></td></tr><tr valign="top"><td align="left"><p class="tent"> </p></td><td align="left"><p class="tent">Libraries</p></td><td align="left"><p class="tent">POSIX_V6_LPBIG_OFFBIG_LIBS</p></td></tr></table></center></blockquote><h4><a name="tag_04_12_14"></a>EXIT STATUS</h4><blockquote><p>The following exit values shall be returned:</p><dl compact><dt> 0</dt><dd>Successful compilation or link edit.</dd><dt>>0</dt><dd>An error occurred.</dd></dl></blockquote><h4><a name="tag_04_12_15"></a>CONSEQUENCES OF ERRORS</h4><blockquote><p>When <i>c99</i> encounters a compilation error that causes an object file not to be created, it shall write a diagnostic tostandard error and continue to compile other source code operands, but it shall not perform the link phase and return a non-zeroexit status. If the link edit is unsuccessful, a diagnostic message shall be written to standard error and <i>c99</i> exits with anon-zero status. A conforming application shall rely on the exit status of <i>c99</i>, rather than on the existence or mode of theexecutable file.</p></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_04_12_16"></a>APPLICATION USAGE</h4><blockquote><p>Since the <i>c99</i> utility usually creates files in the current directory during the compilation process, it is typicallynecessary to run the <i>c99</i> utility in a directory in which a file can be created.</p><p>On systems providing POSIX Conformance (see the Base Definitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap02.html#tag_02">Chapter 2, Conformance</a>), <i>c99</i> is required only with the C-Language Developmentoption; XSI-conformant systems always provide <i>c99</i>.</p><p>Some historical implementations have created <b>.o</b> files when <b>-c</b> is not specified and more than one source file isgiven. Since this area is left unspecified, the application cannot rely on <b>.o</b> files being created, but it also must beprepared for any related <b>.o</b> files that already exist being deleted at the completion of the link edit.</p><p>Some historical implementations have permitted <b>-L</b> options to be interspersed with <b>-l</b> operands on the command line.For an application to compile consistently on systems that do not behave like this, it is necessary for a conforming application tosupply all <b>-L</b> options before any of the <b>-l</b> options.</p><p>There is the possible implication that if a user supplies versions of the standard functions (before they would be encounteredby an implicit <b>-l c</b> or explicit <b>-l m</b>), 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 on), sothe existence of files named in the same manner as the standard libraries within the <b>-L</b> directories is explicitly stated toproduce unspecified behavior.</p><p>All of the functions specified in the System Interfaces volume of IEEE Std 1003.1-2001 may be made visible byimplementations when the Standard C Library is searched. Conforming applications must explicitly request searching the otherstandard libraries when functions made visible by those libraries are used.</p></blockquote><h4><a name="tag_04_12_17"></a>EXAMPLES</h4><blockquote><ol><li><p>The following usage example compiles <b>foo.c</b> and creates the executable file <b>foo</b>:</p><pre><tt>c99 -o foo foo.c</tt></pre><p>The following usage example compiles <b>foo.c</b> and creates the object file <b>foo.o</b>:</p><pre><tt>c99 -c foo.c</tt></pre><p>The following usage example compiles <b>foo.c</b> and creates the executable file <b>a.out</b>:</p><pre><tt>c99 foo.c</tt></pre><p>The following usage example compiles <b>foo.c</b>, links it with <b>bar.o</b>, and creates the executable file <b>a.out</b>. Itmay also create and leave <b>foo.o</b>:</p><pre><tt>c99 foo.c bar.o</tt></pre></li><li><p>The following example shows how an application using threads interfaces can test for support of and use a programmingenvironment supporting 32-bit <b>int</b>, <b>long</b>, and <b>pointer</b> types and an <b>off_t</b> type using at least 64bits:</p><pre><tt>if [ $(getconf _POSIX_V6_ILP32_OFFBIG) != "-1" ]then c99 $(getconf POSIX_V6_ILP32_OFFBIG_CFLAGS) -D_XOPEN_SOURCE=600 \ $(getconf POSIX_V6_ILP32_OFFBIG_LDFLAGS) foo.c -o foo \ $(getconf POSIX_V6_ILP32_OFFBIG_LIBS) -l pthreadelse echo ILP32_OFFBIG programming environment not supported exit 1fi</tt></pre></li><li><p>The following examples clarify the use and interactions of <b>-L</b> options and <b>-l</b> operands.</p><p>Consider the case in which module <b>a.c</b> calls function <i>f</i>() in library <b>libQ.a</b>, and module <b>b.c</b> callsfunction <i>g</i>() in library <b>libp.a</b>. Assume that both libraries reside in <b>/a/b/c</b>. The command line to compile andlink in the desired way is:</p><pre><tt>c99 -L /a/b/c main.o a.c -l Q b.c -l p</tt></pre><p>In this case the <b>-l Q</b> operand need only precede the first <b>-l p</b> operand, since both <b>libQ.a</b> and<b>libp.a</b> reside in the same directory.</p><p>Multiple <b>-L</b> operands can be used when library name collisions occur. Building on the previous example, suppose that theuser wants to use a new <b>libp.a</b>, in <b>/a/a/a</b>, but still wants <i>f</i>() from <b>/a/b/c/libQ.a</b>:</p><pre><tt>c99 -L /a/a/a -L /a/b/c main.o a.c -l Q b.c -l p</tt></pre><p>In this example, the linker searches the <b>-L</b> options in the order specified, and finds <b>/a/a/a/libp.a</b> before<b>/a/b/c/libp.a</b> when resolving references for <b>b.c</b>. The order of the <b>-l</b> operands is still important, however.</p></li><li><p>The following example shows how an application can use a programming environment where the widths of the following types:</p><blockquote><b>blksize_t</b>, <b>cc_t</b>, <b>mode_t</b>, <b>nfds_t</b>, <b>pid_t</b>, <b>ptrdiff_t</b>, <b>size_t</b>,<b>speed_t</b>, <b>ssize_t</b>, <b>suseconds_t</b>, <b>tcflag_t</b>, <b>useconds_t</b>, <b>wchar_t</b>, <b>wint_t</b></blockquote><p>are no greater than the width of type <b>long</b>:</p><pre><tt># First choose one of the listed environments ...<br># ... if there are no additional constraints, the first one will do:CENV=$(getconf _POSIX_V6_WIDTH_RESTRICTED_ENVS | head -n l)<br># ... or, if an environment that supports large files is preferred,# look for names that contain "OFF64" or "OFFBIG". (This chooses# the last one in the list if none match.)for CENV in $(getconf _POSIX_V6_WIDTH_RESTRICTED_ENVS)do case $CENV in *OFF64*|*OFFBIG*) break ;; esacdone<br># The chosen environment name can now be used like this:<br>c99 $(getconf ${CENV}_CFLAGS) -D _POSIX_C_SOURCE=200112L \$(getconf ${CENV}_LDFLAGS) foo.c -o foo \$(getconf ${CENV}_LIBS)</tt></pre></li></ol></blockquote><h4><a name="tag_04_12_18"></a>RATIONALE</h4><blockquote><p>The <i>c99</i> utility is based on the <i>c89</i> utility originally introduced in the ISO POSIX-2:1993 standard.</p><p>Some of the changes from <i>c89</i> include the modification to the contents of the Standard Libraries section to account fornew headers and options; for example, <a href="../basedefs/spawn.h.html"><i><spawn.h></i></a> added to the <b>-l rt</b>operand, and the <b>-l</b> trace operand added for the Tracing functions.</p></blockquote><h4><a name="tag_04_12_19"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_12_20"></a>SEE ALSO</h4><blockquote><p><a href="xcu_chap01.html#tag_01_07_01_04"><i>File Read, Write, and Creation</i></a> , <a href="ar.html"><i>ar</i></a> , <a href="getconf.html"><i>getconf</i></a> , <a href="make.html"><i>make</i></a> , <a href="nm.html"><i>nm</i></a> , <a href="strip.html"><i>strip</i></a> , <a href="umask.html"><i>umask</i>()</a> , the System Interfaces volume ofIEEE Std 1003.1-2001, <i>exec</i>, <a href="../functions/sysconf.html"><i>sysconf</i>()</a>, the Base Definitions volumeof IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap13.html#tag_13">Chapter 13, Headers</a></p></blockquote><h4><a name="tag_04_12_21"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 6. Included for alignment with the ISO/IEC 9899:1999 standard.</p><p>IEEE Std 1003.1-2001/Cor 1-2002, item XCU/TC1/D6/12 is applied, correcting the EXTENDED DESCRIPTION of<b>-l c</b> and <b>-l m</b>. Previously, the text did not take into account the presence of the <i>c99</i> mathheaders.</p><p>IEEE Std 1003.1-2001/Cor 1-2002, item XCU/TC1/D6/13 is applied, changing the reference to the <b>libxnet</b> libraryto <b>libxnet.a</b>.</p></blockquote><div class="box"><em>End of informative text.</em></div><hr><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX ® is a registered Trademark of The Open Group.<br>POSIX ® is a registered Trademark of The IEEE.<br>[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>]</font></center><!--footer end--><hr size="2" noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -