Chapter 9. Libraries, Headers, and Frameworks
This chapter discusses the linking phase of building Unix-based software under Mac OS X. In particular, header files and libraries are covered.
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
POSIX.4
compliance is built into
the system header files. The preprocessor variables _ ANSI_SOURCE
, _ _STRICT_ANSI_ _
, and
_POSIX_SOURCE
are supported. Because Mac OS X
itself is not POSIX.4 compliant, you cannot
achieve strict POSIX.4 compliance. Using these
mechanisms, however, is the best way to approximate
POSIX.4 compliance.
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 if the header file is located in the directory /usr/include.
- #include <directory/headername.h>
This form is used if the header file is located in the ...
Get Mac OS X Panther for Unix Geeks, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.