Header Files
There are two types of header files in Mac OS X.
- Ordinary header files
These header files are inserted into source code by a preprocessor prior to compilation. Ordinary header files have a .h extension.
- Precompiled header files
These header files have a .p extension.
Header files serve four functions:
They contain C declarations.
They contain macro definitions.
They provide for conditional compilation.
They provide line control when combining multiple source files into a single file that is subsequently compiled.
Tip
The mechanism for enabling strict POSIX.1
compliance is built into the system header files. The
preprocessor variables _ANSI_SOURCE, __STRICT_ANSI_ _, and _POSIX_SOURCE are
supported.
Unix developers will find the ordinary header files familiar, since
they follow the BSD convention. The C preprocessor directive
#include
includes a header file in a C source
file. There are essentially three forms of this syntax:
-
#include <headername.h> This form is used when the header file is located in the directory /usr/include.
-
#include <directory/headername.h> This form is used when the header file is located in the directory /usr/include/
directory, wheredirectoryis a subdirectory of /usr/include.-
#include "headername.h" This form is used when the header file is located in a user or nonstandard directory. The form should either be in the same directory as the source file you are compiling or in a directory specified by cc’s -I
directoryswitch.
You can use ...