Re: Forward declaration of C# types in managed C++ headers
- From: "Vladimir Nesterovsky" <vladimir@xxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 21 Jul 2005 11:22:59 +0200
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
.
- Follow-Ups:
- Re: Forward declaration of C# types in managed C++ headers
- From: Eckart Haug
- Re: Forward declaration of C# types in managed C++ headers
- References:
- Forward declaration of C# types in managed C++ headers
- From: Eckart Haug
- Forward declaration of C# types in managed C++ headers
- Prev by Date: Re: How to convert unmanaged string with char array type to managed string with char array type?
- Next by Date: Build Problem - Debug Vs Release
- Previous by thread: Forward declaration of C# types in managed C++ headers
- Next by thread: Re: Forward declaration of C# types in managed C++ headers
- Index(es):
Relevant Pages
|