wesnoth-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Wesnoth-dev] Improving compile time - forward class declarations


From: David White
Subject: Re: [Wesnoth-dev] Improving compile time - forward class declarations
Date: Wed, 09 Mar 2005 15:18:26 -0600
User-agent: Mozilla Thunderbird 0.8 (Windows/20040913)

I think this is a good idea, something which good coding practice dictates should have been done in the first place, and something which we should do now.

The only real caveat that I should note is that a container may only hold a complete type. i.e.

class myclass;
std::vector<myclass> v;

is not valid, though many implementations will allow it.

David

Yann Dirson wrote:

There are a number of header files which only use some classes in
function/method prototypes, and do not have any real use of the full
class definition and all stuff defined in the corresponding header
file.  Doing this causes many headers to be indirectly included by cpp
files, and then surely increases compilation time.

Ex: many headers include display.hpp, just because the function
prototypes declare passing a display object by pointer or reference.

Final #includers may not have a use for these includes, since they may
just pass a pointer or reference they got as a parameter down to other
functions, without really using them.

mapgen and cavegen are perfect examples, where even the implementation
has no use for the display object.

Would there any problem to replace these includes by simple forward
class declarations in the relevant header files (eg. "class display;"
in mapgen.hpp) ?






reply via email to

[Prev in Thread] Current Thread [Next in Thread]