1. | Welcome | ToC | FAQ | Resources | Courses | Projects | Mail Lists | Members | Misc |
2. | Fundamentals | Languages | Tools | Net | Core | Advanced |
3. | EoC | Java |
4. | Lessons |
5. | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 |


Essence of C
11 - LIBRARIES, LINKING AND HEADER FILES

Origins and Nature of C, Libraries, Linking, Compilation, Memory Map, Language Fundamentals, Keywords

The Linker

The output of the compiler is relocatable object code.

The linker has two functions:

The output of the linker is an executable file.

Linking With Overlays

Many C compiler manufacturers supply an overlay linker. An overlay linker works like a normal linker but can also create overlays. An overlay is a piece of object code that is stored in a disk file and loaded and executed only when needed.

The place in memory where an overlay is loaded is called an overlay region. Overlays allow the creation of programs which are larger than available memory.

Sometimes a better alternative to overlays is chaining, in which one program instructs the operating system to load and execute another program. Some compilers provide a chaining function, which is often called exec().

The C Standard Library

The C standard library provides the object code for the functions provided with the compiler. The ANSI standard has defined both the content and the form of the C standard library; however, many compilers supply additional functions.

Libraries Versus Object Files

Libraries are similar to object files; however, the difference is that not all of the contents of the library is added to the program during linking. Unlike an object file, a library file stores the name of each function in the file, enabling the linker to look for the functions referenced in the program and add that code to the program.

Header Files

Many functions in the standard library work with their own specific data types, to which the program must have access. These types are defined in header files supplied with the compiler and must be #included in any file which uses the specific functions to which they refer.

If the header files conform to the ANSI standard, they also contain the function prototypes for the functions related to that file, providing stronger type checking during compilation.

The standard header files defined by the ANSI standard are as follows:

Header File Description
ASSERT.H Defines the assert() macro.
CTYPE.H Character handling.
ERRNO.H Error reporting.
FLOAT.H Defines implementation-dependent floating point values.
LIMITS.H Defines implementation-dependent various limits.
LOCALE.H Supports the setlocal() function.
MATH.H Various definitions used by the math library.
SETJMP.H Supports non-local jumps.
SIGNAL.H Defines signal values.
STDARG.H Supports variable-length argument lists.
STDDEF.H Defines some commonly used constants.
STDIO.H Supports file I/O.
STDLIB.H Miscellaneous declarations.
STRING.H Supports string functions.
TIME.H Supports system time functions.

Macros in Header Files

Many of the C standard functions are actually macro definitions contained in a header file.

Prior Chapter · Index


Copyright © 1996, 1997, 1998. Last Update to This Page: 1998/10/24
This Page Maintained by: radar pangaean * * * Original Author: K.J.Bricknell
The MOST web site is built and maintained by the voluntary efforts/donations of our members.