This is the mail archive of the
mailing list for the Cygwin project.
Re: Homogenizing include guards - and copyright comments
- From: Robert Collins <rbcollins at cygwin dot com>
- To: Max Bowsher <maxb at ukf dot net>
- Cc: "Gary R. Van Sickle" <g dot r dot vansickle at worldnet dot att dot net>, cygwin-apps at cygwin dot com
- Date: Sat, 21 Jun 2003 09:51:21 +1000
- Subject: Re: Homogenizing include guards - and copyright comments
- References: <NCBBIHCHBLCMLBLOBONKKEGBEEAA.email@example.com> <054001c33783$4f4e7090$7a82883e@pomello>
Max Bowsher wrote:
Off-list (presumably accidentally), Gary R. Van Sickle replied:
I tend to think that the include guards should wrap as much of the file as
possible, idea being that the compiler then bypasses the most text
But then again, rumor has it that gcc (at least) recognizes such
doesn't even rescan the file at all the second time, and scanning is
bottleneck in gcc these days....
I don't think the extra copyright comments will have much of an effect on
compilation speed. I like the layout I proposed, because it gives increased
visual distinction between copyright boilerplate and file-specific
I too like this aspect of the layout.
Additionally, recall that C / C++ compilers generally run in (at least)
two parts: a pre-processor (cpp) that generates a single macro-expanded
source files, and then the actual source->(object|assembly).
The smarts of the cpp program are what drive the overhead of repeated
includes. A naive one will scan every include fully into memory, and the
process through the #if's. A smarter one will calculate as it goes, and
once it hits a #if start skipping code...
My point is that a dumb one will, if header FOO is included 3 times,
have three complete copies of FOO in memory before it's #if resolution
pass. A smart one that only keeps one copy of FOO, and 2 copies of the
comments is already so much faster :}....