From -3080038566497142524
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,307cbe6f0ea2ccd3
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2003-06-09 16:05:42 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!kibo.news.demon.net!mutlu.news.demon.net!demon!mail2news.demon.co.uk!devnull
From: andreytarasevich@hotmail.com (Andrey Tarasevich)
Newsgroups: comp.std.c++
Subject: Re: Recommendation to the Standards Committee
Date: Mon, 9 Jun 2003 23:05:41 +0000 (UTC)
Organization: Posted via Supernews, http://www.supernews.com
Lines: 63
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <3EE506BB.3050909@hotmail.com>
References: <ohQDa.44053$4_1.12732776@twister.nyc.rr.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=KOI8-R
Content-Transfer-Encoding: 7bit
X-Trace: mail2news.demon.co.uk 1055199941 18408 10.0.0.1 (9 Jun 2003 23:05:41 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Mon, 9 Jun 2003 23:05:41 +0000 (UTC)
X-Received: from mulga.cs.mu.oz.au ([128.250.1.22])
	by news.demon.co.uk with esmtp (Exim 4.12)
	id 19PVhs-0004ml-00
	for mail2news@news.news.demon.net; Mon, 09 Jun 2003 23:05:40 +0000
X-Received: by mulga.cs.mu.OZ.AU
	id JAA06115; Tue, 10 Jun 2003 09:05:37 +1000 (EST)
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Path: comp-std-cpp-robomod!not-for-mail
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Delivered-To: std-c++@ucar.edu
X-Newsgroups: comp.std.c++
X-User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0
X-Accept-Language: en-us, en
X-Spam-Status: No, hits=-11.3 required=5.0
	tests=FORGED_HOTMAIL_RCVD,NOSPAM_INC,QUOTED_EMAIL_TEXT,
	      REFERENCES,SIGNATURE_SHORT_DENSE,SPAM_PHRASE_03_05,
	      USER_AGENT,USER_AGENT_MOZILLA_UA,X_ACCEPT_LANG
	version=2.41
Xref: archiver1.google.com comp.std.c++:19671

Brian Plummer wrote:
> ...
> Well, almost all of the code I write is portable to a large number of
> Hardware/OS/Compiler combinations and I (try to) employ a technique to
> reduce compile times discussed by Lakos on pages 82-88 of "Large Scale C++
> Software Design" which advocates protecting every #include file directive
> with a redundant check for previous inclusion of said header in the
> translation unit.  An example could be:
> 
> #ifndef __IOSTREAM__
> #include <iostream>
> #endif
> 
> This is what I would use if I was using the cygwin hosted gcc 3.1 that is
> installed on my Windows machine.  If I want to accomplish this same thing
> with MSVC (Microsoft Visual Studio .NET 2003) I would have to use the
> following:
> 
> #ifndef _IOSTREAM_
> #include <iostream>
> #endif
> 
> The problem here is that the MSVC header guard for iostream only uses one
> (1) underscore instead of 2 as in the gcc header guard for iostream.  So, if
> I compile my code using the gcc header guard check as displayed in the first
> example with MSVC, my attempt at eliminating redundant inclusion fails,
> silently, because the header guards are different.
> 
> I'm assuming that you are familiar with this technique.  If not, you should
> take a quick look at the pages I site from Lakos.  Its a very
> straight-forward technique and when carefully employed it can dramatically
> reduce compile times on large projects, especially if the standard library
> headers are widely referred to in the project's header files which is
> becoming ever more prevalent with the exploding use of template classes and
> functions.
> 
> If the header guard text was standardized then I can employ this technique
> without having to worry about how Library Vendor X has assembled the header
> guard text.
> ...

Well, since you are already doing as much as putting this '#ifndef'/'#endif'
guard _outside_ the header file (i.e. add it to every '#include' that refers
to this file), it really won't make things much harder if you add an
additional '#define' into the mix. Just make up your own guard names for
every header file and use them like this:

#ifndef MY_IOSTREAM_INCLUDED_
#define MY_IOSTREAM_INCLUDED_
#include <iostream>
#endif // MY_IOSTREAM_INCLUDED_

-- 
Best regards,
Andrey Tarasevich
Brainbench C and C++ Programming MVP

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]



