Managed and Unmanaged structures
-
I think this overlaps somewhat with the general problems people seem to have with mixing C++ and MC++ code when pointers enters the equation, but anyways, here it the problem: I have an unmanaged struct like so:
__nogc struct foo { int data_; };
and then I have a managed struct like so:__gc struct bar { foo is_this_unmanaged_still; };
And...this doesn't compile. : error C3633: cannot define 'is_this_unmanaged_still' as a member of managed 'bar' I don't have my MC++ books yet, so excuse me if this is a bit of a naff question, but I am in the middle of porting some C++ code to be cross-C++/MC++ compatible and these little diddlers are causing me some immediate headaches...;P cheers -=jarl=- -
I think this overlaps somewhat with the general problems people seem to have with mixing C++ and MC++ code when pointers enters the equation, but anyways, here it the problem: I have an unmanaged struct like so:
__nogc struct foo { int data_; };
and then I have a managed struct like so:__gc struct bar { foo is_this_unmanaged_still; };
And...this doesn't compile. : error C3633: cannot define 'is_this_unmanaged_still' as a member of managed 'bar' I don't have my MC++ books yet, so excuse me if this is a bit of a naff question, but I am in the middle of porting some C++ code to be cross-C++/MC++ compatible and these little diddlers are causing me some immediate headaches...;P cheers -=jarl=- -
..sorry, the question wasn't really in there now, was it...? my question is: why doesn't this work ? ...I have feeling I might have asked a completely stupid question here.... ;P -=jarl=-
Hello there, The following compiles...
#include "stdafx.h"
#using #include using namespace System;
__nogc struct StdHello
{
int nSomething;
};__value struct MCHello
{
StdHello member;
};// This is the entry point for this application
int _tmain(void)
{
// TODO: Please replace the sample code below with your own.
Console::WriteLine(S"Hello World");MCHello hello; hello.member.nSomething = 2003227; Console::WriteLine(\_\_box(hello.member.nSomething)); return 0;
}
I hope you see the difference ;P It pays to buy a book, if not read the MC++ reference it is quite informative. Best regards, Paul. Jesus Christ is LOVE! Please tell somebody.
-
Hello there, The following compiles...
#include "stdafx.h"
#using #include using namespace System;
__nogc struct StdHello
{
int nSomething;
};__value struct MCHello
{
StdHello member;
};// This is the entry point for this application
int _tmain(void)
{
// TODO: Please replace the sample code below with your own.
Console::WriteLine(S"Hello World");MCHello hello; hello.member.nSomething = 2003227; Console::WriteLine(\_\_box(hello.member.nSomething)); return 0;
}
I hope you see the difference ;P It pays to buy a book, if not read the MC++ reference it is quite informative. Best regards, Paul. Jesus Christ is LOVE! Please tell somebody.
-
Ok, yes, I am waiting impatiently for my books, so in the meantime I'm abusing the nice people at CodeProj... ;) Ok, you've answered my question; You can only contain a managed structure in another managed structure. cheers -=jarl=-
-=jarl=- wrote: Ok, you've answered my question; You can only contain a managed structure in another managed structure. No you did not get it, __nogc means StdHello is unmanaged. __value means MCHello is a managed structure, better called value. Best regards, Paul. Jesus Christ is LOVE! Please tell somebody.
-
-=jarl=- wrote: Ok, you've answered my question; You can only contain a managed structure in another managed structure. No you did not get it, __nogc means StdHello is unmanaged. __value means MCHello is a managed structure, better called value. Best regards, Paul. Jesus Christ is LOVE! Please tell somebody.