Re: Forward declaration of C# types in managed C++ headers
- From: Eckart Haug <Eckart.Haug@xxxxxx>
- Date: Thu, 21 Jul 2005 17:01:56 +0200
Thanx for the quick reply. Your suggestion would mean that I'd have to add a C# reference to any C++ module that includes the C++ header. There's lots of them and I'd (for the moment) like to have the C++ <-> C# interface encapsulated in one C++ module.
Vladimir Nesterovsky wrote:
You can add your C# assembly in a project's references thus you may not import it explicitly.
--
Vladimir Nesterovsky
e-mail: vladimir@xxxxxxxxxxxxxxxxxxxx
home: http://www.nesterovsky-bros.com
I'm working with C# objects from managed C++ using the gcroot template.
There'a a C++ header containing the definition of a C++ class:
#using <mscorlib.dll> #include <vcclr.h> #using <CSharpModule.dll>
class CPlusPlusClass { ....
gcroot<TLNameSpace::SubNameSpace::SomeType*> _csharpInstance;
.... }
and a C++ source file containing the class definition
#include "CPlusPlusClass.h" using namespace TLNameSpace::SubNameSpace;
void CPlusPlusClass::createCSharp() { gcroot = new SomeType(); }
void CPlusPlusClass::doSomething() { gcroot->someCSharpMethod(); }
.....
In this example, I need the #using <CSharpModule.dll> directive in the C++ header. One way to avoid this is
to split CPlusPlusClass into CPlusPlusInterface and CPlusPlus Implementation.
A more elegant technique in C++ would be a forward declaration for TLNameSpace::SubNameSpace::SomeType in
the C++ header. However, I didn't find out how to do this.
The most promising try was
namespace TLNameSpace { namespace SubNameSpace { __gcc class SomeType; } }
At least the header compiled. On the #using <CSharpModule.dll> line, I got an 'already defined' error.
Obviously C++ and C# namespaces are just a little bit the same ....
My question is:
- Is there a way to do the forward declaration described above ?
I'd appreciate any hint/solution for this
.
- References:
- Forward declaration of C# types in managed C++ headers
- From: Eckart Haug
- Re: Forward declaration of C# types in managed C++ headers
- From: Vladimir Nesterovsky
- Forward declaration of C# types in managed C++ headers
- Prev by Date: Re: function templates are not being compiled !
- Next by Date: Re: Drag & Drop User Control
- Previous by thread: Re: Forward declaration of C# types in managed C++ headers
- Next by thread: Build Problem - Debug Vs Release
- Index(es):