Thread: RE: [Cppunit-devel] Duplicated #includes
Brought to you by:
blep
From: Summerwill, B. <BSu...@eu...> - 2001-09-25 13:30:49
|
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. >> 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 ? Yes! Looks like it's only used in assertion_traits<T>::toString() and in TestFactoryRegistry::registerFactory(), so that would be sensible. The new header file would then #include Portability.h, for its pre-processor defines. If that's done, then the duplicated includes information I sent would no longer be valid, but the solution would be better, I think. Cheers, Bob -----Original Message----- From: Baptiste Lepilleur [mailto:gai...@fr...] Sent: 25 September 2001 14:06 To: Cpp Unit Develpment Mailing List Subject: Re: [Cppunit-devel] Duplicated #includes Quoting "Summerwill, Bob" <BSu...@eu...>: > > I've just had a quick scan through CppUnit 1.6.0, and found these > duplicated > #includes. The <string> ones are due to addition of a <string> #include > in > Portability.h, making the other ones unnecessary. Shoudln't that <string> only be included if you don't have CPPUNIT_HAVE_SSTREAM anyway ? 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 ? Baptiste. > Source file Duplicated include > ----------- ------------------ > extensions/HelperMacros.h string > extensions/TestFactoryRegistry.h string > extensions/TestSuiteBuilder.h > cppunit/extensions/TypeInfoHelper.h > TestAssert.h string > TestCase.cpp cppunit/Exception.h > TestCase.h string > TestSuite.h string > TypeInfoHelper.cpp string > > > > Cheers, > Bob > > _______________________________________________ > Cppunit-devel mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppunit-devel > --- Baptiste Lepilleur <gai...@fr...> http://gaiacrtn.free.fr/index.html Language: English, French _______________________________________________ Cppunit-devel mailing list Cpp...@li... https://lists.sourceforge.net/lists/listinfo/cppunit-devel |
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 |
From: Steve M. R. <ste...@vi...> - 2001-09-25 14:41:02
|
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 |