include files

Andi Hellmund andi@mail.lxgcc.net
Wed Aug 17 22:35:00 GMT 2011


Hi Jason,

> Hello I have a problem, I have 2 header files that need to include
> each other (engine.h&  controller.h).
This is problematic because you'll end up including the files endlessly. 
You might then see this error:

1.h:1:15: error: #include nested too deeply

> However when I try to compile it
> never seems to include controller.h in engine.h when controller.h
> includes engine.h.
>    
I think that the header files are using include guards to NOT include 
the same file multiple times. An include guard looks like this:

#ifndef _INCLUDE_FILE_XXX
#define _INCLUDE_FILE_XXX

<content of header file>

#endif

> To get this to work correctly what do I have to do ? ( make changes to
> the preprocessors perhaps ?)
>    
Well, I think that you already include these two files, but maybe the 
logic in your header files is not correct.

What is your exact problem/error message that you face?

Best regards,
Andi



More information about the Gcc-help mailing list