📄 library_1.html
字号:
<A NAME="IDX35"></A><P>The exact set of features available when you compile a source fileis controlled by which <DFN>feature test macros</DFN> you define.<P>If you compile your programs using <SAMP>`gcc -ansi'</SAMP>, you get onlythe ANSI C library features, unless you explicitly request additionalfeatures by defining one or more of the feature macros.See section 'Options' in <CITE>The GNU CC Manual</CITE>, for more informationabout GCC options.<P>You should define these macros by using <SAMP>`#define'</SAMP> preprocessordirectives at the top of your source code files. You could also use the <SAMP>`-D'</SAMP> option to GCC, but it's better if you make the sourcefiles indicate their own meaning in a self-contained way.<P><A NAME="IDX36"></A><U>Macro:</U> <B>_POSIX_SOURCE</B><P>If you define this macro, then the functionality from the POSIX.1standard (IEEE Standard 1003.1) is available, as well as all of theANSI C facilities.<P><A NAME="IDX37"></A><U>Macro:</U> <B>_POSIX_C_SOURCE</B><P>If you define this macro with a value of <CODE>1</CODE>, then thefunctionality from the POSIX.1 standard (IEEE Standard 1003.1) is madeavailable. If you define this macro with a value of <CODE>2</CODE>, then boththe functionality from the POSIX.1 standard and the functionality fromthe POSIX.2 standard (IEEE Standard 1003.2) are made available. This isin addition to the ANSI C facilities.<P><A NAME="IDX38"></A><U>Macro:</U> <B>_BSD_SOURCE</B><P>If you define this macro, functionality derived from 4.3 BSD Unix isincluded as well as the ANSI C, POSIX.1, and POSIX.2 material.<P>Some of the features derived from 4.3 BSD Unix conflict with thecorresponding features specified by the POSIX.1 standard. If thismacro is defined, the 4.3 BSD definitions take precedence over thePOSIX definitions.<P><A NAME="IDX39"></A><U>Macro:</U> <B>_SVID_SOURCE</B><P>If you define this macro, functionality derived from SVID isincluded as well as the ANSI C, POSIX.1, and POSIX.2 material.<P><A NAME="IDX40"></A><U>Macro:</U> <B>_GNU_SOURCE</B><P>If you define this macro, everything is included: ANSI C, POSIX.1,POSIX.2, BSD, SVID, and GNU extensions. In the cases where POSIX.1conflicts with BSD, the POSIX definitions take precedence.<P>If you want to get the full effect of <CODE>_GNU_SOURCE</CODE> but make theBSD definitions take precedence over the POSIX definitions, use thissequence of definitions:<P><PRE>#define _GNU_SOURCE#define _BSD_SOURCE#define _SVID_SOURCE</PRE><P>We recommend you use <CODE>_GNU_SOURCE</CODE> in new programs.If you don't specify the <SAMP>`-ansi'</SAMP> option to GCC and don't defineany of these macros explicitly, the effect as the same as defining<CODE>_GNU_SOURCE</CODE>.<P>When you define a feature test macro to request a larger class offeatures, it is harmless to define in addition a feature test macro fora subset of those features. For example, if you define<CODE>_POSIX_C_SOURCE</CODE>, then defining <CODE>_POSIX_SOURCE</CODE> as well hasno effect. Likewise, if you define <CODE>_GNU_SOURCE</CODE>, then definingeither <CODE>_POSIX_SOURCE</CODE> or <CODE>_POSIX_C_SOURCE</CODE> or<CODE>_SVID_SOURCE</CODE> as well has no effect.<P>Note, however, that the features of <CODE>_BSD_SOURCE</CODE> are not a subsetof any of the other feature test macros supported. This is because itdefines BSD features that take precedence over the POSIX features thatare requested by the other macros. For this reason, defining<CODE>_BSD_SOURCE</CODE> in addition to the other feature test macros doeshave an effect: it causes the BSD features to take priority over theconflicting POSIX features.<P><H2><A NAME="SEC13" HREF="library_toc.html#SEC13" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC13">Roadmap to the Manual</A></H2><P>Here is an overview of the contents of the remaining chapters ofthis manual.<P><UL><LI>section <A HREF="library_2.html#SEC14" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_2.html#SEC14">Error Reporting</A>, describes how errors detected by the libraryare reported.<P><LI>section <A HREF="library_28.html#SEC470" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_28.html#SEC470">C Language Facilities Implemented By the Library</A>, contains information about library support forstandard parts of the C language, including things like the<CODE>sizeof</CODE> operator and the symbolic constant <CODE>NULL</CODE>, and how towrite functions accepting variable numbers of arguments.<P><LI>section <A HREF="library_3.html#SEC18" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_3.html#SEC18">Memory Allocation</A>, describes the GNU library's facilities fordynamic allocation of storage. If you do not know in advance how muchstorage your program needs, you can allocate it dynamically instead,and manipulate it via pointers.<P><LI>section <A HREF="library_4.html#SEC54" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_4.html#SEC54">Character Handling</A>, contains information about characterclassification functions (such as <CODE>isspace</CODE>) and functions forperforming case conversion.<P><LI>section <A HREF="library_5.html#SEC57" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_5.html#SEC57">String and Array Utilities</A>, has descriptions of functions formanipulating strings (null-terminated character arrays) and generalbyte arrays, including operations such as copying and comparison.<P><LI>section <A HREF="library_6.html#SEC66" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_6.html#SEC66">Extended Characters</A>, contains information about manipulatingcharacters and strings using character sets larger than will fit inthe usual <CODE>char</CODE> data type. <P><LI>section <A HREF="library_7.html#SEC76" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_7.html#SEC76">Locales and Internationalization</A>, describes how selecting a particular country or language affects the behavior of the library. For example, the localeaffects collation sequences for strings and how monetary values areformatted.<P><LI>section <A HREF="library_8.html#SEC86" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_8.html#SEC86">Searching and Sorting</A>, contains information about functionsfor searching and sorting arrays. You can use these functions on anykind of array by providing an appropriate comparison function.<P><LI>section <A HREF="library_10.html#SEC108" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_10.html#SEC108">Input/Output Overview</A>, gives an overall look at the input and outputfacilities in the library, and contains information about basic conceptssuch as file names.<P><LI>section <A HREF="library_11.html#SEC117" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_11.html#SEC117">Input/Output on Streams</A>, describes I/O operations involving streams (or<CODE>FILE *</CODE> objects). These are the normal C library functionsfrom <TT>`stdio.h'</TT>.<P><LI>section <A HREF="library_12.html#SEC171" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_12.html#SEC171">Low-Level Input/Output</A>, contains information about I/O operationson file descriptors. File descriptors are a lower-level mechanismspecific to the Unix family of operating systems.<P><LI>section <A HREF="library_13.html#SEC187" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_13.html#SEC187">File System Interface</A>, has descriptions of operations on entirefiles, such as functions for deleting and renaming them and for creatingnew directories. This chapter also contains information about how youcan access the attributes of a file, such as its owner and file protectionmodes.<P><LI>section <A HREF="library_14.html#SEC211" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_14.html#SEC211">Pipes and FIFOs</A>, contains information about simple interprocesscommunication mechanisms. Pipes allow communication between two relatedprocesses (such as between a parent and child), while FIFOs allowcommunication between processes sharing a common file system.<P><LI>section <A HREF="library_15.html#SEC216" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_15.html#SEC216">Sockets</A>, describes a more complicated interprocess communicationmechanism that allows processes running on different machines tocommunicate over a network. This chapter also contains information aboutInternet host addressing and how to use the system network databases,such as <TT>`/etc/hosts'</TT>.<P><LI>section <A HREF="library_16.html#SEC268" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_16.html#SEC268">Low-Level Terminal Interface</A>, describes how you can change theattributes of a terminal device. If you want to disable echo ofcharacters typed by the user, for example, read this chapter.<P><LI>section <A HREF="library_28.html#SEC471" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_28.html#SEC471">Explicitly Checking Internal Consistency</A>, contains information about a simpledebugging mechanism. You can put assertions in your code, anddiagnostic messages are printed if the test fails.<P><LI>section <A HREF="library_17.html#SEC290" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_17.html#SEC290">Mathematics</A>, contains information about the math libraryfunctions. These include things like random-number generators andremainder functions on integers as well as the usual trigonometric andexponential functions on floating-point numbers.<P><LI>section <A HREF="library_19.html#SEC309" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_19.html#SEC309">Date and Time</A>, describes functions for measuring both calendar timeand CPU time, as well as functions for setting alarms and timers.<P><LI>section <A HREF="library_20.html#SEC326" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_20.html#SEC326">Non-Local Exits</A>, contains descriptions of the <CODE>setjmp</CODE> and<CODE>longjmp</CODE> functions.<P><LI>section <A HREF="library_21.html#SEC330" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_21.html#SEC330">Signal Handling</A>, tells you all about signals--what they are,how to establish a handler that is called when a particular kind ofsignal is delivered, and how to prevent signals from arriving duringcritical sections of your program.<P><LI>section <A HREF="library_23.html#SEC401" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_23.html#SEC401">Child Processes</A>, contains information about how to start new processesand run programs.<P><LI>section <A HREF="library_22.html#SEC385" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_22.html#SEC385">Process Startup and Termination</A>, tells how your programs can access theircommand-line arguments and environment variables.<P><LI>section <A HREF="library_24.html#SEC411" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_24.html#SEC411">Job Control</A>, describes functions for manipulating process groups.This material is probably only of interest if you are writing a shell.<P><LI>section <A HREF="library_25.html#SEC441" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_25.html#SEC441">User Database</A>, and section <A HREF="library_25.html#SEC446" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_25.html#SEC446">Group Database</A>, tell you how to accessthe system user and group databases.<P><LI>section <A HREF="library_26.html#SEC451" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_26.html#SEC451">System Information</A>, describes functions for getting informationabout the hardware and software configuration your program is executingunder.<P><LI>section <A HREF="library_28.html#SEC486" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_28.html#SEC486">Range of an Integer Type</A>, contains information aboutparameters that characterize the sizes of integer and floating-pointtypes used by the particular C implementation that your program hasbeen compiled with. Most of these parameters are provided for compatibility with ANSI C.<P><LI>section <A HREF="library_27.html#SEC454" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_27.html#SEC454">System Configuration Parameters</A>, tells you how you can getinformation about various operating system limits. Most of theseparameters are provided for compatibility with POSIX.</UL><P>If you already know the name of the facility you are interested in, youcan look it up in section <A HREF="library_29.html#SEC492" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_29.html#SEC492">Summary of Library Facilities</A>. This gives you a summary ofits syntax and a pointer to where you can find a more detaileddescription. This appendix is particularly useful if you just want toverify the order and type of arguments to a function, for example.<P>Go to the <A HREF="library_2.html" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_2.html">next</A> section.<P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -