RD/EE Controls<P> EPICURE Design Note 116.0<P> <b> Avoiding Multiply Included Header Files</b>

RD/EE Controls

EPICURE Design Note 116.0

Avoiding Multiply Included Header Files

Brian J. Kramper

There are a number of header files which are used by more than one process and presently reside in either EPICURE_INC or EPICURE_SYS_INC. Several of these header files include other header files from within this domain. As a result, from time to time a new application will attempt to include several of these header files in an order which results in multiple definitions during compilation. In the past some effort has been made to circumvent this problem by using #ifndef with a symbol from the file to be included. In order to establish consistency across all proccesses coded within this group, the following norm will be adhered to.

The first compilable statement within the header file itself will be an #ifndef statement using a symbol of the form __XXX.H, where XXX.H is the filename, and __XXX.H is defined within the header file, as the first symbol. The last compilable statement within the file would be the corresponding #endif statement. This will prevent multiple definitions of symbols caused by multiple attempts to include the same file.

Example:
/*	
 *	File FTD.H
 */
#ifndef __FTD.H
#define __FTD.H
	.
	.
	.
other definitions here
	.
	.
	.
#endif  /*  #ifndef __FTD.H  */
<EOF>

Security, Privacy, Legal

rwest@fsus04.fnal.gov