RE: [Cppunit-devel] Duplicated #includes
Brought to you by:
blep
From: Summerwill, B. <BSu...@eu...> - 2001-09-25 15:07:35
|
They don't cause any trouble as such, but they will increase compile times, maybe substantially. On most compilers, the preprocessor will have to fully expand the second #include (including traversing the indirect includes which the header itself has *), before it can notice the #ifndef, and discard the lot. MSVC++ solves this with #pragma once, but this isn't a portable solution. I just wanted to point these duplications out, as summed over the whole application, they can make a real difference to the compile time. Cheers, Bob * Just starting traversing the headers shipped with MSVC++, including <string> also drags in ... istream ostream ios streambuf xlocnum cerrno errorno.h climits limits.h cstdio stdio.h cstdlib stdlib.h xiosbase xlocale cstring string.h stdexcept exception xstring etc ... So having <string> included twice may well cause an additional 20 or 30 file operations for _each_ client file which uses the header with the duplicated include. -----Original Message----- From: Steve M. Robbins [mailto:ste...@vi...] Sent: 25 September 2001 15:41 To: Cpp Unit Develpment Mailing List Subject: Re: [Cppunit-devel] Duplicated #includes Hello, Sorry for being so dense this morning, but: do the duplicated includes cause any trouble? On Tue, Sep 25, 2001 at 02:30:33PM +0100, Summerwill, Bob wrote: > Baptiste wrote ... > > >> Shoudln't that <string> only be included if you don't have > >> CPPUNIT_HAVE_SSTREAM anyway ? > > I'm not sure. Presumably it's there so that the inline implementation > of OStringStream::str() can construct the msg local variable, in which > case you are probably correct. Yeah, you're right, it could be protected. > >> Wouldn't it be better to move the declaration of OStringStream in > >> its one header (include/cppunit/portability, include/cppunit/tools ?), > >> and includes it only where it is used ? The whole reason for "Portability" is so that you can just #include it, and then assume a whole bunch of things. Like class OStringStream is defined. I would argue that including <string> unconditionally in "Portability.h" is also a good thing. It is true that at present, OStringStream is only used in a couple of the CppUnit sources. However, users that define their own assertion_traits (i.e. ME!) also use OStringStream. It is convenient to include a single CppUnit header and have everything I need defined. As I said above: I don't understand the concern over a few extra includes. -Steve -- by Rocket to the Moon, by Airplane to the Rocket, by Taxi to the Airport, by Frontdoor to the Taxi, by throwing back the blanket and laying down the legs ... - They Might Be Giants _______________________________________________ Cppunit-devel mailing list Cpp...@li... https://lists.sourceforge.net/lists/listinfo/cppunit-devel |