⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 library_1.html

📁 Linux程序员的工作手册
💻 HTML
📖 第 1 页 / 共 3 页
字号:
feature test macro definition (see section <A HREF="library_1.html#SEC12" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_1.html#SEC12">Feature Test Macros</A>).<P>For more information about the use of header files and <SAMP>`#include'</SAMP>directives, see section 'Header Files' in <CITE>The GNU C Preprocessor Manual</CITE>.<P>The GNU C library provides several header files, each of which containsthe type and macro definitions and variable and function declarationsfor a group of related facilities.  This means that your programs mayneed to include several header files, depending on exactly whichfacilities you are using.<P>Some library header files include other library header filesautomatically.  However, as a matter of programming style, you shouldnot rely on this; it is better to explicitly include all the headerfiles required for the library facilities you are using.  The GNU Clibrary header files have been written in such a way that it doesn'tmatter if a header file is accidentally included more than once;including a header file a second time has no effect.  Likewise, if yourprogram needs to include multiple header files, the order in which theyare included doesn't matter.<P><STRONG>Compatibility Note:</STRONG> Inclusion of standard header files in anyorder and any number of times works in any ANSI C implementation.However, this has traditionally not been the case in many older Cimplementations.<P>Strictly speaking, you don't <EM>have to</EM> include a header file to usea function it declares; you could declare the function explicitlyyourself, according to the specifications in this manual.  But it isusually better to include the header file because it may define typesand macros that are not otherwise available and because it may definemore efficient macro replacements for some functions.  It is also a sureway to have the correct declaration.<P><A NAME="IDX21"></A><A NAME="IDX22"></A><A NAME="IDX23"></A><H3><A NAME="SEC10" HREF="library_toc.html#SEC10" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC10">Macro Definitions of Functions</A></H3><P>If we describe something as a function in this manual, it may have amacro definition as well.  This normally has no effect on how yourprogram runs--the macro definition does the same thing as the functionwould.  In particular, macro equivalents for library functions evaluatearguments exactly once, in the same way that a function call would.  Themain reason for these macro definitions is that sometimes they canproduce an inline expansion that is considerably faster than an actualfunction call.<P>Taking the address of a library function works even if it is alsodefined as a macro.  This is because, in this context, the name of thefunction isn't followed by the left parenthesis that is syntacticallynecessary to recognize the  a macro call.<P>You might occasionally want to avoid using the a macro definition of afunction--perhaps to make your program easier to debug.  There aretwo ways you can do this:<P><UL><LI>You can avoid a macro definition in a specific use by enclosing the nameof the function in parentheses.  This works because the name of thefunction doesn't appear in a syntactic context where it is recognizableas a macro call.<P><LI>You can suppress any macro definition for a whole source file by usingthe <SAMP>`#undef'</SAMP> preprocessor directive, unless otherwise statedexplicitly in the description of that facility.</UL><P>For example, suppose the header file <TT>`stdlib.h'</TT> declares a functionnamed <CODE>abs</CODE> with<P><PRE>extern int abs (int);</PRE><P>and also provides a macro definition for <CODE>abs</CODE>.  Then, in:<P><PRE>#include &#60;stdlib.h&#62;int f (int *i) { return (abs (++*i)); }</PRE><P>the reference to <CODE>abs</CODE> might refer to either a macro or a function.On the other hand, in each of the following examples the reference isto a function and not a macro.<P><PRE>#include &#60;stdlib.h&#62;int g (int *i) { return ((abs)(++*i)); }#undef absint h (int *i) { return (abs (++*i)); }</PRE><P>Since macro definitions that double for a function behave inexactly the same way as the actual function version, there is usually noneed for any of these methods.  In fact, removing macro definitions usuallyjust makes your program slower.<P><A NAME="IDX24"></A><A NAME="IDX25"></A><H3><A NAME="SEC11" HREF="library_toc.html#SEC11" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC11">Reserved Names</A></H3><P>The names of all library types, macros, variables and functions thatcome from the ANSI C standard are reserved unconditionally; your program<STRONG>may not</STRONG> redefine these names.  All other library names arereserved if your programs explicitly includes the header file thatdefines or declares them.  There are several reasons for theserestrictions:<P><UL><LI>Other people reading your code could get very confused if you were usinga function named <CODE>exit</CODE> to do something completely different fromwhat the standard <CODE>exit</CODE> function does, for example.  Preventingthis situation helps to make your programs easier to understand andcontributes to modularity and maintainability.<P><LI>It avoids the possibility of a user accidentally redefining a libraryfunction that is called by other library functions.  If redefinitionwere allowed, those other functions would not work properly.<P><LI>It allows the compiler to do whatever special optimizations it pleaseson calls to these functions, without the possibility that they may havebeen redefined by the user.  Some library facilities, such as those fordealing with variadic arguments (see section <A HREF="library_28.html#SEC472" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_28.html#SEC472">Variadic Functions</A>)and non-local exits (see 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>), actually require aconsiderable amount of cooperation on the part of the C compiler, andimplementationally it might be easier for the compiler to treat these asbuilt-in parts of the language.</UL><P>In addition to the names documented in this manual, reserved namesinclude all external identifiers (global functions and variables) thatbegin with an underscore (<SAMP>`_'</SAMP>) and all identifiers regardless ofuse that begin with either two underscores or an underscore followed bya capital letter are reserved names.  This is so that the library andheader files can define functions, variables, and macros for internalpurposes without risk of conflict with names in user programs.<P>Some additional classes of identifier names are reserved for futureextensions to the C language.  While using these names for your ownpurposes right now might not cause a problem, they do raise thepossibility of conflict with future versions of the C standard, so youshould avoid these names.<P><UL><LI>Names beginning with a capital <SAMP>`E'</SAMP> followed a digit or uppercaseletter may be used for additional error code names.  See 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>.<P><LI>Names that begin with either <SAMP>`is'</SAMP> or <SAMP>`to'</SAMP> followed by alowercase letter may be used for additional character testing andconversion functions.  See 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>.<P><LI>Names that begin with <SAMP>`LC_'</SAMP> followed by an uppercase letter may beused for additional macros specifying locale attributes.See 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>.<P><LI>Names of all existing mathematics functions (see 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>)suffixed with <SAMP>`f'</SAMP> or <SAMP>`l'</SAMP> are reserved for correspondingfunctions that operate on <CODE>float</CODE> or <CODE>long double</CODE> arguments,respectively.<P><LI>Names that begin with <SAMP>`SIG'</SAMP> followed by an uppercase letter arereserved for additional signal names.  See section <A HREF="library_21.html#SEC335" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_21.html#SEC335">Standard Signals</A>.<P><LI>Names that begin with <SAMP>`SIG_'</SAMP> followed by an uppercase letter arereserved for additional signal actions.  See section <A HREF="library_21.html#SEC345" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_21.html#SEC345">Basic Signal Handling</A>.<P><LI>Names beginning with <SAMP>`str'</SAMP>, <SAMP>`mem'</SAMP>, or <SAMP>`wcs'</SAMP> followed by alowercase letter are reserved for additional string and array functions.See 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>.<P><LI>Names that end with <SAMP>`_t'</SAMP> are reserved for additional type names.</UL><P>In addition, some individual header files reserve names beyondthose that they actually define.  You only need to worry about theserestrictions if your program includes that particular header file.<P><UL><LI>The header file <TT>`dirent.h'</TT> reserves names prefixed with<SAMP>`d_'</SAMP>.<A NAME="IDX26"></A><P><LI>The header file <TT>`fcntl.h'</TT> reserves names prefixed with<SAMP>`l_'</SAMP>, <SAMP>`F_'</SAMP>, <SAMP>`O_'</SAMP>, and <SAMP>`S_'</SAMP>.<A NAME="IDX27"></A><P><LI>The header file <TT>`grp.h'</TT> reserves names prefixed with <SAMP>`gr_'</SAMP>.<A NAME="IDX28"></A><P><LI>The header file <TT>`limits.h'</TT> reserves names suffixed with <SAMP>`_MAX'</SAMP>.<A NAME="IDX29"></A><P><LI>The header file <TT>`pwd.h'</TT> reserves names prefixed with <SAMP>`pw_'</SAMP>.<A NAME="IDX30"></A><P><LI>The header file <TT>`signal.h'</TT> reserves names prefixed with <SAMP>`sa_'</SAMP>and <SAMP>`SA_'</SAMP>.<A NAME="IDX31"></A><P><LI>The header file <TT>`sys/stat.h'</TT> reserves names prefixed with <SAMP>`st_'</SAMP>and <SAMP>`S_'</SAMP>.<A NAME="IDX32"></A><P><LI>The header file <TT>`sys/times.h'</TT> reserves names prefixed with <SAMP>`tms_'</SAMP>.<A NAME="IDX33"></A><P><LI>The header file <TT>`termios.h'</TT> reserves names prefixed with <SAMP>`c_'</SAMP>,<SAMP>`V'</SAMP>, <SAMP>`I'</SAMP>, <SAMP>`O'</SAMP>, and <SAMP>`TC'</SAMP>; and names prefixed with<SAMP>`B'</SAMP> followed by a digit.<A NAME="IDX34"></A></UL><P><H3><A NAME="SEC12" HREF="library_toc.html#SEC12" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC12">Feature Test Macros</A></H3>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -