Index Home About Blog
From: Linus Torvalds <torvalds@osdl.org>
Newsgroups: fa.linux.kernel
Subject: Re: RFC: cleaning up the in-kernel headers
Date: Tue, 11 Jul 2006 22:43:45 UTC
Message-ID: <fa.kELlMaplBnP3oOy4zo5c8i6ogGQ@ifi.uio.no>
Original-Message-ID: <Pine.LNX.4.64.0607111537080.5623@g5.osdl.org>

On Tue, 11 Jul 2006, H. Peter Anvin wrote:
>
> #1 I doubt the time taken to look at include files that are #ifndef'd in their
> entirety is significant (I think there is special code in gcc to handle this
> case fast.)

Correct. Don't worry about multiple includes.

HOWEVER. If you can avoid the include entirely, that can be an absolutely
huge timesaver. Much of the compile time is from just parsing the things
the first time around (rather than parsing it over and over), and if you
don't strictly need a header, avoiding parsing it in the first place is a
big big issue.

For example, if a header only needs a structure to be declared because it
uses a pointer to it, then rather than including the header file that
declares that structure fully, just doing a

	struct task_struct;

to say that "there is such a thing as a 'struct task_struct'" can be a
huge time-saver.

Of course, anything that actually needs to look past the pointer will need
to get the full declaration..

		Linus

Index Home About Blog