Introduction
A .inc file is a piece of source code that another file pulls in. It is not a
format of its own: the extension only says “include me”, and the contents are in whatever
language the including file uses. Shared constants, macros and declarations are the usual
contents.
Structure
The file is plain text, in the syntax of its language. These are the common uses:
| Language or tool | How it is included | What to look for |
|---|---|---|
| Assembly (NASM, MASM, TASM) | %include or include | Lines of mnemonics, equ constants, ; comments |
| Pascal and Delphi | {$I name.inc} | {$ compiler directives, procedure, begin |
| PHP | include or require | <?php |
| C and C++ | #include | #define, lines ending in ; |
| Fortran | INCLUDE | COMMON blocks, PARAMETER |
| HTML, ASP and server-side includes | <!--#include --> | Tags |
| POV-Ray | #include | Scene description: #declare, #macro, texture { |
| BitBake | require or include | Recipe variables |
Nothing in the file marks which of these it is. The file viewer on this site reads the text and judges from its shape: PHP from its opening tag, assembly from lines of mnemonics, and Pascal or C from which of them finds more of its own words. It colours the file to match and says what it decided. Where nothing reads well, the file is shown plain.
Pascal is named only when the text has at least two marks that belong to Pascal and
that Fortran, INI and batch text do not have: a line of begin with a later
end; or end.; a {$ directive with a Pascal word
({$IFDEF, {$I, {$mode); a unit,
program, library or package header; a line of
interface, implementation, var, const,
type or label on its own; a uses list; a
procedure or function heading ending in a semicolon; a type
declared as record, class, array, set of or a
pointer; and := assignments ending in a semicolon (these count only beside one
of the other marks). A batch label :begin, an INI line such as
type = exe or a Fortran type point is not one. C or C++ is named
for preprocessor lines, brace lines and comments, or, when nothing else reads, for at
least two declarations that end in a semicolon.
Not described
Known, not yet covered
- Reference: the table names eight common uses. It does not describe the include rules of each language: where an included file is searched for, whether it is read once or every time, nesting limits, and how the including file’s symbols and macros reach it. The languages themselves have their own pages (assembly, C, POV-Ray), but there are none for Fortran, BitBake or server-side includes.
- Viewer: the kinds it tells apart are assembly (by processor), POV-Ray, PHP, HTML, Pascal and C or C++. A Fortran or BitBake include file is shown plain, but a Fortran file whose lines happen to look like assembly (a quarter of its lines starting with
endor other assembler words) is read as assembly, and a C-like file with brace lines is read as C. - Viewer: the choice is made from the first 256 KiB of the text and from its shape alone, by counting lines, so a short file (a single constant or a few lines) may read as the wrong language or as none. Assembly is named for a processor only when the text clearly says so. Only the first 1 MiB of a file is read and coloured.
Also used for
- POV-Ray include file – A part of a POV-Ray scene (declarations, macros, objects) pulled in with #include.