Header file

A header file is in the programming, especially in the programming languages ​​C and C, a text file that contains declarations and other components of the source code. Source code, which is located in a header file is generally intended for use in multiple programs or multiple parts of a program.

Task of a header file

To facilitate the use with medium or large programs are divided into several programs called translation units. Here belong together source code components are summarized in files called header files that are referenced by integration into the source code from other files can be referenced. The header files thus form the interface between the individual units.

By organizing in header files and a recompilation of people accessing the interface programs or program components to changes in the implementation can be avoided.

In libraries header files form the visible part of the library, whereas the rest often pretranslated in translation units, so not in source code form, is present.

The inclusion of a header file in a translation unit by the translation program is initiated about special instructions. In C, for example, by the compiler directive # include.

# include   / * ... ( Another program text ) * / In this case, the file is included stdio.h contains the declarations of functions that are important for reading and writing files and user input. It is part of the standard C library libc.

Alternatives

Header files work on the principle of textual substitution. Newer programming languages ​​such as Java or C #, this concept is no longer needed. Instead, units are integrated, offering no more text but symbol information. This allows for better separation between interface and implementation, and usually results in shorter build times.

  • C ( programming language)
  • C
380145
de