Original Post
Hi all, As I've been discussing in this thread: [VC++] Compile times for large projects recently, I've been looking at improving compile times. I'm starting a new thread, because this is a bit too specific to tag on the end of the previous thread. Basically, I'm familiar with the concept of forward declarations in a header file so that you don't have to #include the full definition of a class when you're just using it as a parameter/return type. However, everything I've seen is great when you "own" the header files that the class/symbol is defined in. None of what I've read covers (for example) playing the same tricks with windows.h or d3dx9.h - i.e. SDK header files that you don't really want to mess too much with (because they can change subtly if you install/upgrade the relevent SDK). As an example, due to a small hack required by my graphics engine, I need to declare the standard Win32 WndProc() as a public function. Yet it only uses the LRESULT, HWND, LPARAM etc... definitions - nothing else. #include windows.h to get ONLY those few definitions seems overkill. But I haven't quite worked out how to safely (if possible) forward declare those types so that I only need include windows.h in the main implementation file. Likewise with d3dx9.h - I really only need definitions for 'IDirect3D9', 'IDirect3DDevice9', 'IDirect3DTexture9' etc... Is there any clever way of doing this? is it safe to just forward declare ("class IDirect3D9;" at the top) these classes and then include the files in the implementation? I can see a substantial compile time improvement if my 'graphics' class definition ("Graphics.h") doesn't have to drag around a copy of windows.h && d3dx9.h... Any thoughts/hints? Cheers, Jack