Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

Header-Files.html 7.1KB

pirms 3 gadiem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1987-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation. A copy of
  7. the license is included in the
  8. section entitled "GNU Free Documentation License".
  9. This manual contains no Invariant Sections. The Front-Cover Texts are
  10. (a) (see below), and the Back-Cover Texts are (b) (see below).
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <title>Header Files (The C Preprocessor)</title>
  21. <meta name="description" content="Header Files (The C Preprocessor)">
  22. <meta name="keywords" content="Header Files (The C Preprocessor)">
  23. <meta name="resource-type" content="document">
  24. <meta name="distribution" content="global">
  25. <meta name="Generator" content="makeinfo">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Index-of-Directives.html#Index-of-Directives" rel="index" title="Index of Directives">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="index.html#Top" rel="up" title="Top">
  30. <link href="Include-Syntax.html#Include-Syntax" rel="next" title="Include Syntax">
  31. <link href="The-preprocessing-language.html#The-preprocessing-language" rel="prev" title="The preprocessing language">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.indentedblock {margin-right: 0em}
  36. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  37. blockquote.smallquotation {font-size: smaller}
  38. div.display {margin-left: 3.2em}
  39. div.example {margin-left: 3.2em}
  40. div.lisp {margin-left: 3.2em}
  41. div.smalldisplay {margin-left: 3.2em}
  42. div.smallexample {margin-left: 3.2em}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style: oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nolinebreak {white-space: nowrap}
  54. span.roman {font-family: initial; font-weight: normal}
  55. span.sansserif {font-family: sans-serif; font-weight: normal}
  56. ul.no-bullet {list-style: none}
  57. -->
  58. </style>
  59. </head>
  60. <body lang="en">
  61. <a name="Header-Files"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Macros.html#Macros" accesskey="n" rel="next">Macros</a>, Previous: <a href="Overview.html#Overview" accesskey="p" rel="prev">Overview</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index-of-Directives.html#Index-of-Directives" title="Index" rel="index">Index</a>]</p>
  65. </div>
  66. <hr>
  67. <a name="Header-Files-1"></a>
  68. <h2 class="chapter">2 Header Files</h2>
  69. <a name="index-header-file"></a>
  70. <p>A header file is a file containing C declarations and macro definitions
  71. (see <a href="Macros.html#Macros">Macros</a>) to be shared between several source files. You request
  72. the use of a header file in your program by <em>including</em> it, with the
  73. C preprocessing directive &lsquo;<samp>#include</samp>&rsquo;.
  74. </p>
  75. <p>Header files serve two purposes.
  76. </p>
  77. <ul>
  78. <li> <a name="index-system-header-files"></a>
  79. System header files declare the interfaces to parts of the operating
  80. system. You include them in your program to supply the definitions and
  81. declarations you need to invoke system calls and libraries.
  82. </li><li> Your own header files contain declarations for interfaces between the
  83. source files of your program. Each time you have a group of related
  84. declarations and macro definitions all or most of which are needed in
  85. several different source files, it is a good idea to create a header
  86. file for them.
  87. </li></ul>
  88. <p>Including a header file produces the same results as copying the header
  89. file into each source file that needs it. Such copying would be
  90. time-consuming and error-prone. With a header file, the related
  91. declarations appear in only one place. If they need to be changed, they
  92. can be changed in one place, and programs that include the header file
  93. will automatically use the new version when next recompiled. The header
  94. file eliminates the labor of finding and changing all the copies as well
  95. as the risk that a failure to find one copy will result in
  96. inconsistencies within a program.
  97. </p>
  98. <p>In C, the usual convention is to give header files names that end with
  99. <samp>.h</samp>. It is most portable to use only letters, digits, dashes, and
  100. underscores in header file names, and at most one dot.
  101. </p>
  102. <table class="menu" border="0" cellspacing="0">
  103. <tr><td align="left" valign="top">&bull; <a href="Include-Syntax.html#Include-Syntax" accesskey="1">Include Syntax</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  104. </td></tr>
  105. <tr><td align="left" valign="top">&bull; <a href="Include-Operation.html#Include-Operation" accesskey="2">Include Operation</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  106. </td></tr>
  107. <tr><td align="left" valign="top">&bull; <a href="Search-Path.html#Search-Path" accesskey="3">Search Path</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  108. </td></tr>
  109. <tr><td align="left" valign="top">&bull; <a href="Once_002dOnly-Headers.html#Once_002dOnly-Headers" accesskey="4">Once-Only Headers</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  110. </td></tr>
  111. <tr><td align="left" valign="top">&bull; <a href="Alternatives-to-Wrapper-_0023ifndef.html#Alternatives-to-Wrapper-_0023ifndef" accesskey="5">Alternatives to Wrapper #ifndef</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  112. </td></tr>
  113. <tr><td align="left" valign="top">&bull; <a href="Computed-Includes.html#Computed-Includes" accesskey="6">Computed Includes</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  114. </td></tr>
  115. <tr><td align="left" valign="top">&bull; <a href="Wrapper-Headers.html#Wrapper-Headers" accesskey="7">Wrapper Headers</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  116. </td></tr>
  117. <tr><td align="left" valign="top">&bull; <a href="System-Headers.html#System-Headers" accesskey="8">System Headers</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
  118. </td></tr>
  119. </table>
  120. <hr>
  121. <div class="header">
  122. <p>
  123. Next: <a href="Macros.html#Macros" accesskey="n" rel="next">Macros</a>, Previous: <a href="Overview.html#Overview" accesskey="p" rel="prev">Overview</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index-of-Directives.html#Index-of-Directives" title="Index" rel="index">Index</a>]</p>
  124. </div>
  125. </body>
  126. </html>