Link to home
Start Free TrialLog in
Avatar of jjacksn
jjacksn

asked on

URGENT: Header Files / Linking Problem

I have a COM dll I am writing with 4 different interfaces / classes.  I have some classes, structs and globals defined in a .H file (its all in the .H file, there is no cpp file)

When I include the .H file in one of the headers for the 4 classes, I have no problem.

When I include the .H file in two of the headers for the 4 classes, I get all sorts of

SYMBOLICFucntionName already definien in Object2.obj, where Object2 is the second object I added the #include directive to.  There are no errors for Object1, the original object that #included my header with objects and enums.  

Am I not allowed to do this?  If not, how do I restrucutre the linking/files so that I can do something like this?  
If so, why is this not working?
SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jjacksn
jjacksn

ASKER

I added them, it didn' t fix the problem.
Avatar of jjacksn

ASKER

Also, when I don't have the header in there, I can't access the objects in the class that is causing the problems, so I don't think I have multiple inclusion problems.  I think it has something to do with the fact that they are all in the COM class perhaps? the .h file is creating global objects.  just a thought.  
This _usually_ fixes the problem you described. Are you sure the #ifndef/#endif part encloses *all* of your file? Could you post the code?
>its all in the .H file, there is no cpp file
You have to split them on cpp and h.
There is no good way to solve the problem, if you have a code in your H file not only headers.
Other way:

---myh.h---
void SomeFunc(void);

#ifndef CODE_ALREADY_DEFINED
void SomeFunc(void)
{
}
#endif
--------------

---file1.cpp---
#include "myh.h"
----------------

---file2.cpp---
#define CODE_ALREADY_DEFINED
#include "myh.h"
----------------

---file3.cpp---
#define CODE_ALREADY_DEFINED
#include "myh.h"
----------------

...
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial