Re: include guard weirdness

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Michal Marek <mmarek@xxxxxxx> writes:

> On 2014-07-11 13:51, Rasmus Villemoes wrote:
>> Hi,
>> 
>> gcc/cpp claims to be smart enough to recognize the include guard idiom,
>> and most of the time this works very well: the second and subsequent
>> #includes do not even cause the file to be opened (thus saving at least
>> open+fstat+read+close). Except in a few cases, which are so common that
>> it might be worth investigating.
>> 
>> For example, linux/mm.h often shows up exactly twice in strace output;
>> another very common header such as linux/types.h always occurs only
>> once.
>
> My guess is that <linux/mm.h> includes a header which at some point
> includes <linux/mm.h> again.

Indeed. I naively thought that the kernel didn't have any cyclic
includes, but if ever I was wrong about something... 

The cycle is very short (mm.h and vmstat.h include each
other). Including vmstat.h before mm.h breaks the build. 

Thanks for enlightening me,
Rasmus
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux