Ogre STD Headers

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
Post Reply
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56
Contact:

Ogre STD Headers

Post by Klaim »

I didn't made yet a deep analysis of the situation but I would like to ask experts and the Ogre team:
Am I correct that the header OgreStdHeaders.h is certainly the biggest source of compilation time in Ogre?
It is included in OgrePrerequisites.h , which is included in almost all Ogre headers, and it have this kind of thing:
#include <fstream>
#include <iostream>
#include <iomanip>
#include <sstream>
I was trying to understand why this header even exist, maybe it was because of a precompiled-header setup, but it looks strange because totally bloated.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Ogre STD Headers

Post by dark_sylinc »

Ogre needs a session of analyzing all headers and removal of bogus dependencies. But no one's found the time yet, and I don't know about tools in aiding this (AFAIK the boost guys build their own tool to visualize include headers)

It appears to be included in OgrePrerequisites so that the "std headers" get included after all macro settings have been set, mostly to deal with compiler variations i.e.:

Code: Select all

#if (OGRE_COMPILER == OGRE_COMPILER_GNUC) && !defined(STLPORT)
#   if OGRE_COMP_VER >= 430
#       include <tr1/unordered_map>
#elif (OGRE_COMPILER == OGRE_COMPILER_CLANG)
#   if defined(_LIBCPP_VERSION)
#       include <unordered_map>
#   endif
However, IMO including std headers in all files is insane (other than vector and string).
Though I don't think the problem is a single file, but rather that every file ends up including almost every file.
User avatar
Mikachu
Gnoll
Posts: 603
Joined: Thu Jul 28, 2005 4:11 pm
Location: Nice, France
x 35

Re: Ogre STD Headers

Post by Mikachu »

A while ago I tried to dig into the problem of Ogre headers, but never quite finished the work...

Here's what I found :
- There's this little tool analysing which header includes what in a C++ project : https://bitbucket.org/bitsquid/header_hero/downloads (but it doesn't perform any analysis about compile time for each header, which could be handy)
- There's massive inclusion between Ogre headers.
One cause for that used to be shared ptrs, as they needed to know the full type of the class they were pointing at.
I submitted a patch for this, but didn't have the time/courage to run an analysis to see what heaer dependencies could be subsequently removed.
- Another cause for massive inclusion is sometimes use of inner typedefs/constants/enums : instead of forward declaring the class in the header, you need to include its header.
- All of that process of improving compile times is a hard task, but would be very useful to the community (compiling Ogre itself is no longer a problem with unity builds, but every project using Ogre get bad compile times because of headers)
OgreProcedural - Procedural Geometry for Ogre3D
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56
Contact:

Re: Ogre STD Headers

Post by Klaim »

Interesting points. I'll think for a battle plan to help on this in a few months (when I'll have time a bit more time to apply the plan).
I think it is not natural, even for C++, that Ogre take so much time to build (ignoring the unity build mode).
User avatar
Mikachu
Gnoll
Posts: 603
Joined: Thu Jul 28, 2005 4:11 pm
Location: Nice, France
x 35

Re: Ogre STD Headers

Post by Mikachu »

I forgot to say, I'm currently trying to write a pimpl interface generator for Ogre, which would solve those issues from a user point of view, but I'm still not sure I'll succeed (containers/templates of Ogre types don't mix well with the pimpl idiom)
OgreProcedural - Procedural Geometry for Ogre3D
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56
Contact:

Re: Ogre STD Headers

Post by Klaim »

Mikachu wrote:I forgot to say, I'm currently trying to write a pimpl interface generator for Ogre, which would solve those issues from a user point of view, but I'm still not sure I'll succeed (containers/templates of Ogre types don't mix well with the pimpl idiom)
Oh wow, that would be very useful!
Post Reply