Include

from Wikipedia, the free encyclopedia

Include ( English include , to include , Latin. Includere, to include , to lock up, to attach, to limit ), also called an include statement , is in programming an instruction to the compiler or its preprocessor contained in the source code of a computer program , a piece of code specified as a parameter to be inserted in the edited source code. In the program code temporarily generated for further processing, especially for translation, the content of the included elements is used instead of the include statement; the original plus all inserted text parts thus form the actual program code. In contrast, the original source text remains unchanged, i.e. i.e. it only contains the include statement (s).

The parts to be inserted are mostly data declarations or routines or fragments thereof. They were created and made available so that they can be used in identical form in several programs , essentially to avoid redundancies in the program source code . The use of the include technique thus partly corresponds to the principles of modular programming: Each program detail exists only once, in the event of maintenance only one point has to be actively modified, and during testing (except for the first use), high test coverage for the inserted code mostly be waived. In addition, however, compilations and, if necessary, further implementation measures (such as testing) are required for all programs in which the changed element is used.

Delimitation: 'Include' is the insertion of program text in the context of programming. In contrast, 'import (ier)' is the transfer / insertion of technical and operational data in the operation of a program, in addition to 'export (ier)' belongs to the term data exchange .

Other uses

Outside of programming, include commands are also used in other contexts, for example:

  • as tags with which the Mediawiki software selectively transfers parts of one page to another.

Differences depending on the programming language

Depending on the programming language , sometimes also depending on the language version, include statements can be named differently , have a different syntax , optionally contain further parameters (which are taken into account when implementing the include statement - such as inserting from explicitly definable libraries, replacing of text elements), or they are only valid in certain program sections. See examples.

  • C or C ++ : #include; Standard library or individual include file can be assigned; Parameter = 'header.h'.
  • Cobol : command = include or copy; in the data or procedure division. Objects to be inserted are also called copy elements, copy series, copybook or (colloquially) "copy" or "include". Texts can optionally be replaced by others (replace parameter).
  • Assembly language : Include functions are often implemented as macros . Which functionality is possible, for example renaming variable names, depends on the implementation of the macro.

Web links

Individual evidence

  1. see: Help: Templates #Conditional integration of source text blocks
  2. Uni Halle archive link ( Memento of the original from November 20, 2012 in the Internet Archive ) Info: The archive link has been inserted automatically and has not yet been checked. Please check the original and archive link according to the instructions and then remove this notice. Preprocessor / include @1@ 2Template: Webachiv / IABot / www2.informatik.uni-halle.de