1



Tuesday November 26 (Sessions 1 and 2)

1. #include dependencies vs. forward declarations

Include dependencies:

#include “random_number_generator.h”

struct Something {

Random_Number_Generator generator;

};

Forward declaration:

struct Random_Number_Generator;

struct Something {

Random_Number_Generator *generator;

};

Forward declaration provides a tremendous increase in speed when used consistently in a large project. The disadvantage is that the compiler doesn’t know the size of the forward-declared type, so you can’t use that type directly in the header. You must instead use a pointer to the type. So the semantics of your program are affected (you need to dynamically allocate things sometimes when you might prefer not to). This way in which compile-speed concerns bleed into the semantics of your program can be viewed as a general weakness of C++.

2. Compiler timing experiments performed by Casey Muratori of RAD Game Tools

Date: Wed, 20 Sep 2000 19:09:24 -0400 (EDT)

From: Casey Muratori

Recently, I decided to run some very simple tests on my machine to get a baseline for just how bad the STL (and templates in general) can be. Even on my 1gHz machine with a supposedly super-fast memory subsystem and all that mumbo jumbo, I was able to bring the compiler to its knees with some very simple STL statements. Simple things like including and instantiating a std::string bloated compile time by a half a second per file, which can really add up for large projects. Instantiating something like std::map was far worse, bloating compile time by more than a second per file. And, needless to say, over-the-top STL statements like std::list ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download