From owner-freebsd-stable Wed Aug 29 22:56:47 2001 Delivered-To: freebsd-stable@freebsd.org Received: from astaroth.sdezmio.org (amgj56hvy558c.ab.hsia.telus.net [142.59.146.125]) by hub.freebsd.org (Postfix) with ESMTP id 637AA37B403 for ; Wed, 29 Aug 2001 22:56:31 -0700 (PDT) (envelope-from danilo@telusplanet.net) Received: (from shade@localhost) by astaroth.sdezmio.org (8.11.6/8.11.6) id f7U5tqs06476; Wed, 29 Aug 2001 23:55:52 -0600 (MDT) (envelope-from danilo@telusplanet.net) To: Gregory Bond Cc: Chris BeHanna , FreeBSD-Stable Subject: Re: CPUTYPE and ports References: <200108300342.NAA07776@lightning.itga.com.au> From: Danilo Fiorenzano Date: 29 Aug 2001 23:54:37 -0600 In-Reply-To: <200108300342.NAA07776@lightning.itga.com.au> Message-ID: Lines: 36 User-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.1 (Cuyahoga Valley) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Gregory Bond 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 #include 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