Re: [Algorithms] OT: Include hell
Brought to you by:
vexxed72
From: Erwin de V. <er...@vo...> - 2001-08-01 17:42:20
|
Beware. I've had VERY weird bugs doing this. I use it a lot myself as well, but i once spent a day trying to find a bug, and NOT doing forward declarations fixed it. The problem was that msvc was offsetting locations inside a class with 100 bytes too little or too much (dont remember). I posted this at the sweng gamedev list. It appeared to be a compiler bug, but we never resolved or reported this, because i didnt have a clue what could such a thing. We worked around it by simply including the headers. Just telling y'all. Erwin -----Original Message----- From: Jeffrey Rainy <jr...@he...> To: gda...@li... <gda...@li...> Date: Wednesday, August 01, 2001 5:58 PM Subject: Re: [Algorithms] OT: Include hell >Last time we had that problem, the solution was quite simple : > >We removed all #include from the includes files that we could, and replaced >them with forward declarations. The important point is to do it thoroughly. > >For example, we had lots of : > >=== A.h === >#include "B.h" // useless include >class A >{ > public: > private: > B* somePtr; >}; >======= > >Which became : > >=== A.h === >class B; >class A >{ > public: > private: > B* somePtr; >}; >======= > >The only cases where some .h will need to include another one is when you >have inheritance, or when an object contains another one. > >After making changes to all include files, then we managed to "sanely" go >through all source files, and removed all useless #includes. It's long, and >boring, but it is much easier when you go through your include files before. > >HTH, and good luck. ;-) > >Jeffrey. > > > > >----- Original Message ----- >From: "Sergei Miloikov" <se...@ha...> >To: <gda...@li...> >Sent: Wednesday, August 01, 2001 11:23 >Subject: [Algorithms] OT: Include hell > > >> Little offtopic, but I remember of slightly related discussion right here >so >> here it goes: >> We have problem with our compile time - our in-house tool shown that from >> 160K lines of code compiler must parse about 2.5M lines not including STL >> (77Mb text). I have been searching for some tool for profiling the source >> code structure and especially the include hierarchies, but found none. So, >> does somebody know such a tool? It will be cool if it can determine when >> there is no need of a header, this will be difinitely of great help, >because >> after some reorganizations of source code I found that there are such >> useless includes everywhere. And I have a question - how other people >decide >> where to put constants? It seems that even if everything is ideal (single >> class - single header), if the class is some big, templated piece of lots >of >> inlined code and there is single constant I feel very confused to include >it >> because of that constant! Placing all the constants inside single file is >> pain indeed. Any comments? >> Sergei Miloikov, programmer at Haemimont AD >> >> >> _______________________________________________ >> GDAlgorithms-list mailing list >> GDA...@li... >> http://lists.sourceforge.net/lists/listinfo/gdalgorithms-list > > >_______________________________________________ >GDAlgorithms-list mailing list >GDA...@li... >http://lists.sourceforge.net/lists/listinfo/gdalgorithms-list > > |