quantass
January 20th, 2003, 04:55 AM
I'm having some problems with #include and my header files. I have one header file with the following contents:
---(MyHeader1.h)---
#if !defined(__MyHeader1__)
#define __MyHeader1__
#Include "MyHeader2.h"
class CMyHeader
{
DWORD myfunction(void);
}
#endif
---(MyHeader2.h)---
#if !defined(__MyHeader2__)
#define __MyHeader2__
#include "MyHeader1.h"
typedef unsigned long DWORD;
#endif
---
As you can see MyHeader1.h makes reference to a DWORD type which is defined within MyHeader2.h. Myheader2.h is included but also has the directive to include MyHeader1.h however that file has already #DEFINED its special name and so shall not be included again. What I expect then is for MyHeader2.h to be traversed the rest of the way adding the typedef DWORD and placing all of this info into MyHeader1.h which provides it the necessary info (the DWORD definition) to declare itself.
What I'm experiencing is the typedef DWORD line in MyHeader2.h is never being defined for MyHeader1.h and so I keepreceving a "syntax error: identifier DWORD".
Can someone please explain to me why #include isnt working the way I expect it to.
---(MyHeader1.h)---
#if !defined(__MyHeader1__)
#define __MyHeader1__
#Include "MyHeader2.h"
class CMyHeader
{
DWORD myfunction(void);
}
#endif
---(MyHeader2.h)---
#if !defined(__MyHeader2__)
#define __MyHeader2__
#include "MyHeader1.h"
typedef unsigned long DWORD;
#endif
---
As you can see MyHeader1.h makes reference to a DWORD type which is defined within MyHeader2.h. Myheader2.h is included but also has the directive to include MyHeader1.h however that file has already #DEFINED its special name and so shall not be included again. What I expect then is for MyHeader2.h to be traversed the rest of the way adding the typedef DWORD and placing all of this info into MyHeader1.h which provides it the necessary info (the DWORD definition) to declare itself.
What I'm experiencing is the typedef DWORD line in MyHeader2.h is never being defined for MyHeader1.h and so I keepreceving a "syntax error: identifier DWORD".
Can someone please explain to me why #include isnt working the way I expect it to.