Return-Path: Delivered-To: apmail-stdcxx-dev-archive@www.apache.org Received: (qmail 1620 invoked from network); 23 Jun 2008 13:49:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Jun 2008 13:49:59 -0000 Received: (qmail 19183 invoked by uid 500); 23 Jun 2008 13:50:01 -0000 Delivered-To: apmail-stdcxx-dev-archive@stdcxx.apache.org Received: (qmail 19166 invoked by uid 500); 23 Jun 2008 13:50:01 -0000 Mailing-List: contact dev-help@stdcxx.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stdcxx.apache.org Delivered-To: mailing list dev@stdcxx.apache.org Received: (qmail 19155 invoked by uid 99); 23 Jun 2008 13:50:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Jun 2008 06:50:01 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [208.30.140.160] (HELO moroha.roguewave.com) (208.30.140.160) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Jun 2008 13:49:11 +0000 Received: from nebula.bco.roguewave.com ([10.70.3.27]) by moroha.roguewave.com (8.13.6/8.13.6) with ESMTP id m5NDlSBl013347 for ; Mon, 23 Jun 2008 13:47:28 GMT Message-ID: <485FA971.4040905@roguewave.com> Date: Mon, 23 Jun 2008 07:47:29 -0600 From: Martin Sebor Organization: Rogue Wave Software, Inc. User-Agent: Thunderbird 2.0.0.12 (X11/20080226) MIME-Version: 1.0 To: dev@stdcxx.apache.org Subject: Re: <485ED79C.1080605@roguewave.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Travis Vitek wrote: > Martin Sebor wrote: [...] >> In all library headers: >> >> 1. standard headers (C++, including stdcxx own, C, or POSIX are >> never included (there are a shrinking number of exceptions to >> this rule) > > So, as an example, if one of us needed to use std::integral_constant in some header, the definition of that type would need to be moved to some private header and included from both places to avoid including . I can buy this as it fits with the unnecessary namespace polution problem that keeps coming up. Right. Although it should be balanced against the cost of #including a whole header for just a single definition. That's why we have headers such as or : to group the most commonly needed sets of definitions and not a separate header for each of the definitions in these headers. > >> 2. include directives are in alphabetical order, with rw/_defs.h >> being last (it still ends up getting included first, indirectly, >> by the first header); the exception here is when a stdcxx config >> macro needs to be tested before the first #include directive > > Okay, and what is the rationale for including rw/_defs.h last? If it provides defines that are needed by the current file, why not just put it in the list in alphabetical order like the others? It used to be first. IIRC, the idea behind including it last was to make it more likely for things to break if the #include directive was missing. I'm not sure how well well thought out it was. If it's causing trouble and going back to how it used to be way back when makes more sense (i.e., eliminates the exceptional case) I have no problem with it. > >> 3. each #include directive in every standard header is guarded with >> a preprocessor conditional testing the XXX_INCLUDED macro for >> the corresponding header for compile-time efficiency >> > > I'm assuming that you're talking about this kind of thing... > > #ifndef _RWSTD_RW_ALGOBASE_H_INCLUDED > # include > #endif // _RWSTD_RW_ALGOBASE_H_INCLUDED > > #ifndef _RWSTD_RW_ITERBASE_H_INCLUDED > # include > #endif // _RWSTD_RW_ITERBASE_H_INCLUDED > > I looked in a handful of standard headers and didn't see this model anywhere. I do see it in many of the private headers, but it is not being used consistently. I thought I had implemented it this way but it looks like I misremembered. > > Do we have any evidence that shows this 'optimization' is actually improving compile times? I haven't done any benchmarking with stdcxx but what's in stdcxx now was done based on a user request: http://issues.apache.org/jira/browse/STDCXX-213 Other than that, as I already said in another thread, there is plenty of evidence out there that #include directives can have a dramatic impact on compile times. That's why many modern compilers provide this optimization either via special purpose mechanisms like #pragma once or even automatically. > >> In library sources: >> >> 1. sets of C++, C, POSIX, and stdcxx-private headers are included >> in separate blocks of their own, in alphabetical order within >> each block >> 2. C headers are included using the xxx.h form (as opposed to the >> cxxx form) for better portability >> >> Martin >