Skip site navigation (1)Skip section navigation (2)
Date:      29 Aug 2001 23:54:37 -0600
From:      Danilo Fiorenzano <danilo@telusplanet.net>
To:        Gregory Bond <gnb@itga.com.au>
Cc:        Chris BeHanna <behanna@zbzoom.net>, FreeBSD-Stable <stable@FreeBSD.ORG>
Subject:   Re: CPUTYPE and ports
Message-ID:  <m3k7zmum76.fsf@astaroth.sdezmio.org>
In-Reply-To: <200108300342.NAA07776@lightning.itga.com.au>
References:  <200108300342.NAA07776@lightning.itga.com.au>

next in thread | previous in thread | raw e-mail | index | archive | help
Gregory Bond <gnb@itga.com.au> writes:

> >     What I'd like to know is if anyone has figured out a way to do a
> > g++ equivalent to Microsoft's "precompiled headers".
> 
> Not really needed for gcc.  The preprocessor has special-case logic to
> recognise header files of the form
> 
> 	/* optional comments */
> 	#ifndef SYMBOL
> 	#define SYMBOL
> 	/* Stuff */
> 	#endif
> 
> (i.e. almost any normal C/C++ header) and not bother to even open the file next
> time it is referenced.  This gives most of the speedup that precompiled headers
> would give.  (The remaining bit is avoiding lexing the include file text, but
> that's not such a huge burden).

  Actually, the primary reason for using that construct is to avoid
compile-time errors caused by the same header file being included twice in the
same g++ run.

 The real rationale behind MS-style precompiled headers is to speed up
compilation of separate source modules belonging to the same project,
including one or more of the same headers and that are compiled in successive
runs of the compiler.  This sometimes may make quite a difference, especially
on slow machines and with the STL headers.  Try passing this code:

        #include <iostream>
        #include <map>
        main(){}

to "g++ -E" and see what you end up with ;)

-- Danilo

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?m3k7zmum76.fsf>