How can I avoid type redefinition w/ managed dll and other unmanaged code?

  • Thread starter Thread starter Scott Yost
  • Start date Start date
S

Scott Yost

I have a managed class A which I import via a DLL.
public __gc class A
{
public B otherClass;
}

And another class C which is just in a CPP file - not in the DLL.
#include <b.h>

class C
{
void foo (int x, B bar);
}

The problem comes when I want to use both of these classes in the same
project. When I use class C in most projects, I add the B includes and the B
cpp file to the project, and it all gets compiled together happily

The problem comes when I want to use both classes A and C in one project.
When I reference the A DLL, it adds the types for A and B into the project.
But when I then try to compile C in the same project, it ends up trying to
redefine the B class and I end up with error C2011. (Once from the DLL, and
once from the #include of the B header file)

Is there some way to avoid this so that I can make all my projects compile?
Right now I am working around it by adding a #define into the project
settings for any project which uses the DLL and they just avoid #including
the B header files if the #define is set. I'd like a better way, though.

I hope I was able to make that clear. Thanks for any help you can offer!

Scott
 
I'm having the same problem. Let me know if you find a good solution.

For now I've added all the files into one project. What a mess.
 
Back
Top