#Include Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a simple vc++ win32 program. I have one header that has a list of all
the other header files in it. In each of the .cpp files i make a referance to
this main header. is there a way of getting around this, so i only have to
make one header (listing all the includes i ever would like in the program)
and then reference this once in one main file somewhere?

I am a bit new to the c++ compiler so this doesn't appear to be obvious to me.

Thanks for your help
 
Well, I don't think there is a way to avoid including your
'superchief-include-file', since the compiler must get it's definitions
somewhere.

On the other hand, putting all possible includes is not very nice, certainly
not in bigger projects: 1 change in some include file makes a full
recompilation necessary, since the compiler can no longer see the
dependencies.

Jürgen Devlieghere
 
Hi Jürgen!
On the other hand, putting all possible includes is not very nice, certainly
not in bigger projects: 1 change in some include file makes a full
recompilation necessary, since the compiler can no longer see the
dependencies.

But it is a very good aproch if your use precompiled headers. Then you
normally only need *one* include file (stdafx.h; which contains
everything you need) and the compile-time is very fast...


--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
 
Yes. I think you can do this easily - Just use a preprocessor directive so
that the include files are processed only once, i.e

#ifndef ALL_INCLUDED
#include "h1.h"
#include "h2.h"
#define ALL_INCLUDED
#endif

Or maybe I misunderstood your question?
 
I will try this method and see if it works, thanks.

Also thanks to Jurgen and Jochen for their help
 
Back
Top