Skip to Main Content
Mac OS X for Unix Geeks
book

Mac OS X for Unix Geeks

by Ernest E. Rothman, Brian Jepson
September 2002
Beginner to intermediate content levelBeginner to intermediate
216 pages
7h 43m
English
O'Reilly Media, Inc.
Content preview from Mac OS X for Unix Geeks

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, where directory is 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 directory switch.

You can use ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mac OS X For Unix Geeks, 4th Edition

Mac OS X For Unix Geeks, 4th Edition

Ernest E. Rothman, Rich Rosen, Brian Jepson
Mac OS X Hacks

Mac OS X Hacks

Kevin Hemenway, Rael Dornfest
Mac OS X in a Nutshell

Mac OS X in a Nutshell

Jason McIntosh, Chuck Toporek, Chris Stone

Publisher Resources

ISBN: 0596003560Errata Page