On Tue, 12 Jun 2007 11:39:35 -0700 Allison Randal <[EMAIL PROTECTED]> wrote:
> jerry gay wrote: > > On 6/12/07, Andy Lester <[EMAIL PROTECTED]> wrote: > >> > >> I'm very uncomfortable with removing #pragma once from our header > >> files. It is perfectly valid C89 code, and I think bowing to a > >> broken compiler is unhealthy precedent. > >> > > to add some context, in r18884 andy committed a patch (after my > > suggestion) to put C<#pragma once> in every c header file, after > > reading that it should speed up compilation with msvc. i consulted > > my copy of k&r, which states that unrecognized pragmas should be > > ignored, so it should have no ill effects on other platforms. > > Do we have any proof that it does speed up compilation with msvc? > Littering our code with "optimizations" for odd compilers is also an > unhealthy precedent. Note that some versions of gcc also support it, for instance, later compilers in the 3.4.x series support it. (At least, I see it in their changelog, not sure exactly which release they added it in.) I just came up with an artificial benchmark and found that gcc-3.4.6 runs slightly faster with #pragma once protecting a header that includes lots of other headers. (a chain of 200 other headers, in my test.) By "slightly", I mean "compare a 0.86 second average to a 0.92 second average, for 10 runs each". For a more realistic benchmark, parrot r18883 compiles in 3m29.363s, parrot r18884 compiles in 3m29.190s. So, for gcc-3.4.6 at least, I think the difference might be lost in the noise. On the other hand, will #pragma once allow us to get rid of all of those ugly header guard macros? If so, I would argue to keep it for maintenance reasons, regardless of any performance benefits. Mark