USDA ARS

C preprocessor

The C preprocessor is a powerful tool for enhancing the readability and maintainability of C source code. Use of macros to parameterize literal constants allows those constants to be easily changed should the need arise, and is a useful form of documentation. Collecting oft-used macros and declarations into header files simplifies their maintenance.

Within a source file, preprocessor directives are grouped and ordered as follows:

Each group is preceded by a blank line. Preprocessor directives always begin in column 1. There is no whitespace between the "#" and the directive name. In #define directives, the macro name begins at tab stop 1 (column 9) and the replacement text begins at tab stop 3 (column 25), or at the next available tab stop. In all other directives, a single space separates the directive from the subsequent expression, filename, etc.

Examples:

#include 

#include "ipw.h "

#include "lutx.h "

#define LUT_NBITS       8
#define LUT_SIZE        (1 << LUT_NBITS )
#define	VALID_IDX(i)    ( (i) >= 0 && (i) < LUT_SIZE )


IPW documentation / Last revised 20 May 2009 / IPW web site