316 Chapter 13 The Preprocessor
System Include Files
It was noted that the include file <stddef.h>contains a define for NULLand is often
used for testing to see whether a pointer has a null value. Earlier in this chapter, it was
also noted that the header file <math.h>contains the definition M_PI, which is set to an
approximation for the value of π.
The <stdio.h>header file contains information about the I/O routines contained in
the standard I/O library.This header file is described in more detail in Chapter 16,
“Input and Output Operations in C.”You should include this file whenever you use any
I/O library routine in your program.
Two other useful system include files are <limits.h>and <float.h>.The first file,
<limits.h>, contains system-dependent values that specify the sizes of various character
and integer data types. For instance, the maximum size of an intis defined by the name
INT_MAXinside this file.The maximum size of an unsigned long intis defined by
ULONG_MAX, and so on.
The <float.h>header file gives information about floating-point data types. For
example,FLT_MAXspecifies the maximum floating-point number, and FLT_DIGspecifies
the number of decimal digits of precision for a floattype.
Other system include files contain prototype declarations for various functions stored
inside the system library. For example, the include file <string.h>contains prototype
declarations for the library routines that perform character string operations, such as
copying, comparing, and concatenating.
For more details on these header files, consult Appendix B.
Conditional Compilation
The C preprocessor offers a feature known as conditional compilation. Conditional compi-
lation is often used to create one program that can be compiled to run on different
computer systems. It is also often used to switch on or off various statements in the pro-
gram, such as debugging statements that print out the values of various variables or trace
the flow of program execution.
The #ifdef,#endif,#else, and #ifndefStatements
You were shown earlier in this chapter how you could make the rotatefunction from
Chapter 12 more portable.You saw there how the use of a define would help in this
regard.The definition
#define kIntSize 32
was used to isolate the dependency on the specific number of bits contained in an
unsigned int. It was noted in several places that this dependency does not have to be
made at all because the program can itself determine the number of bits stored inside an
unsigned int.
Unfortunately, a program sometimes must rely on system-dependent parameters—on
a filename, for example—that might be specified differently on different systems or on a
particular feature of the operating system.