A header file is a file of C code that contains definitions, declarations, and structures commonly used in a given situation. By tradition, a header file always has the suffix ``.h''. Header files are invoked within a C program by the command ##iinncclluuddee, which is read by cpp, the C preprocessor; for this reason, they are also called ``include files''.
Header files are one of the most useful tools available to a C programmer. They allow you to put into one place all of the information that the different modules of your program share. Proper use of header files will make your programs easier to maintain and to port to other environments.
COHERENT includes the following header files:
aa..oouutt..hh Include all COFF header files aacccctt..hh Format for process-accounting file aarr..hh Format for archive files aasssseerrtt..hh Define aasssseerrtt(()) ssyyss//bbuuff..hh Buffer header ssyyss//ccddrroomm..hh Definitions for CD-ROM drives ccooffff..hh Format for COHERENT objects ssyyss//ccoonn..hh Configure device drivers ssyyss//ccoorree..hh Declare structure of a ccoorree file ccttyyppee..hh Header file for data tests ccuurrsseess..hh Declare/define ccuurrsseess routines ddbbmm..hh Header file for DBM routines ssyyss//ddeeffttttyy..hh Default tty settings ddiirreenntt..hh Define constant ddiirreenntt eerrrrnnoo..hh Error numbers used by eerrrrnnoo(()) ffccnnttll..hh Manifest constants for file-handling functions ssyyss//ffdd..hh Declare file-descriptor structure ssyyss//ffddiiooccttll..hh Control floppy-disk I/O ssyyss//ffddiisskk..hh Fixed-disk constants and structures ssyyss//ffiillssyyss..hh Structures and constants for super block ffllooaatt..hh Define constants for floating-point numbers ffnnmmaattcchh..hh Constants used with function ffnnmmaattcchh(()) ffppeerrrr..hh Constants used with floating-point exception codes ggddbbmm..hh Header file for GDBM routines ggddbbmmeerrrrnnoo..hh Define error messages used by GDBM routines ggrrpp..hh Declare group structure ssyyss//hhddiiooccttll..hh Control hard-disk I/O ssyyss//iinnoo..hh Constants and structures for i-nodes ssyyss//iinnooddee..hh Constants and structures for memory-resident i-nodes ssyyss//iioo..hh Constants and structures used by I/O ssyyss//iippcc..hh Declarations for interprocess communication ssyyss//kkbb..hh Define keys for loadable keyboard driver ll..oouutt..hh Format for COHERENT-286 objects lliimmiittss..hh Define numerical limits ssyyss//llppiiooccttll..hh Definitions for line-printer I/O control mmaatthh..hh Declare mathematics functions mmnnttttaabb..hh Structure for mount table mmoonn..hh Read profile output files ssyyss//mmoouunntt..hh Define the mount table mmpprreecc..hh Multiple-precision arithmetic ssyyss//mmssgg..hh Definitions for message facility mmttaabb..hh Currently mounted file systems ssyyss//mmttiiooccttll..hh Magnetic-tape I/O control mmttyyppee..hh List processor code numbers nn..oouutt..hh Define nn..oouutt file structure nnddbbmm..hh Header file for NDBM routines nneettddbb..hh Define structures used to describe networks ppaatthh..hh Define/declare constants and functions used with ppaatthh ppoollll..hh Define structures/constants used with polling devices ssyyss//pprroocc..hh Define structures/constants used with processes ssyyss//ppttrraaccee..hh Perform process tracing ppwwdd..hh Define password structure rreeggeexxpp..hh Header file for regular-expression functions ssyyss//sscchheedd..hh Define constants used with scheduling ssyyss//sseegg..hh Definitions used with segmentation ssyyss//sseemm..hh Definitions used by semaphore facility sseettjjmmpp..hh Define sseettjjmmpp(()) and lloonnggjjmmpp(()) ssggttttyy..hh Definitions used to control terminal I/O sshhaaddooww..hh Definitions used with shadow passwords ssyyss//sshhmm..hh Definitions used with shared memory ssiiggnnaall..hh Define signals ssoocckkeett..hh Define constants and structures with ssoocckkeettss ssyyss//ssttaatt..hh Definitions and declarations used to obtain file status ssttddaarrgg..hh Declare/define routines for variable arguments ssttddddeeff..hh Declare/define standard definitions ssttddiioo..hh Declarations and definitions for I/O ssttddlliibb..hh Declare/define general functions ssyyss//ssttrreeaamm..hh Definitions for message facility ssttrriinngg..hh Declare string functions ssttrrooppttss..hh User-level STREAMS routines tteerrmmiioo..hh Definitions used with terminal input and output tteerrmmiiooss..hh Definitions used with POSIX extended terminal interface ttiimmee..hh Give time-description structure ssyyss//ttiimmeebb..hh Define ttiimmeebb structure ssyyss//ttiimmeess..hh Definitions used with ttiimmeess(()) system call ssyyss//ttttyy..hh Define flags used with tty processing ssyyss//ttyyppeess..hh Define system-specific data types uulliimmiitt..hh Define manifest constants used by system call uulliimmiitt(()) uunnccttrrll..hh Define macro uunnccttrrll(()) uunniissttdd..hh Define constants for file-handling routines ssyyss//uupprroocc..hh Definitions used with user processes uuttiimmee..hh Declare system call uuttiimmee(()) uuttmmpp..hh Login accounting information ssyyss//uuttssnnaammee..hh Define uuttssnnaammee structure vvaarraarrggss..hh Declare/define routines for variable arguments ssyyss//wwaaiitt..hh Define wait routines
As discussed in the Lexicon article name space, the ISO Standard" reserves for the implementation every identifier that begins with a single underscore followed by an upper-case letter. The POSIX Standard"s define several symbols in this name space that the implementation can use as ``feature tests'' -- that is, as symbols that you can use in your source code to determine the presence or absence of a particular feature or combination of features. Note that a feature test applies to an implementation of C, rather than to an operating system. A feature test combines aspects of the host system and the language translator: some tests apply to the operating system, some purely to the C translator.
The operating system's header files can define them (for example, _POSIX_SAVED_IDS) to control compilation of user code or to deal with optional features, or you can define them (e.g., _POSIX_C_SOURCE) to control how the system's header files declare or define constants, types, structures, and macros.
In general, a feature test must either be undefined or have an integer value. It must not be defined as having no expansion text, or expand into a string. For example,
# CORRECT
cc -D_POSIX_C_SOURCE=1 foo.c
is correct, as is:
# CORRECT
cc -U_POSIX_C_SOURCE foo.c
However,
# WRONG
cc -D_POSIX_C_SOURCE foo.c
is incorrect, as is:
# WRONG
cc -D_POSIX_C_SOURCE="yes" foo.c
This is to permit the constants to be tested with expressions like
#if _POSIX_C_SOURCE > 1
where an integer value is required. (If the symbol is used in a #if test and is undefined, cpp replaces it with zero, which is still an integer value). This permits the implementation to use different values of the feature test to invoke different feature sets; and it simplifies testing for complex combinations of feature tests.
Although nearly all feature tests behave as shown above, there are a few exceptions, namely _POSIX_SOURCE and _KERNEL. These symbols are not defined as having a specific value, so many users do not supply a value. To deal with this, the COHERENT header files check whether these constants have expansion text. If they do not, the header files redefine these constants with value 1, so that they can be used like the other feature tests that the COHERENT header files define.
The following describes the feature tests used in the COHERENT header files, and briefly describes the compilation environment each invokes. Because we are continually adding new features to the kernel, this list is not guaranteed to be complete.