Re: double include of a header file

Mike A. Harris (mharris@meteng.on.ca)
Tue, 10 Aug 1999 22:06:06 -0400 (EDT)


On Tue, 10 Aug 1999, Joe wrote:

> I am not a C expert so can someone tell me what the benifits
>/ disadvantages of the following lines of code are if there are
>any? The reason I am writning these lists is that I found this
>code in the kernel..
>
>#include <asm/irq.h>
>#include <asm/system.h>
>#include <asm/irq.h>

There are no benefits. However there are no problems either.
Most C header files contain preprocessor directives which
surround the entire header file and protect it against multiple
inclusion. For example:

#ifndef __MYHEADER_H__
#define __MYHEADER_H__

(Headerfile contents go here)

#endif /* __MY_HEADER_H__ */

The only thing multiple inclusion does in this case is it makes
the kernel code a bit sloppier, but it doesn't affect anything so
long as the headers all have multiple inclusion protection as
above.

--
Mike A. Harris                   Linux advocate      GNU advocate
Computer Consultant                          Open Source advocate  

Tea, Earl Grey, Hot...

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/