How to use unmanaged char arrays as class member?
-
Hi, I have a problem when I add an unmanaged character array as an member to a managed class. Here's a simple example:
__nogc class Foo
{
public:
static void Test(char* sz)
{}
};__gc public class Bar
{
public:
void TestFunc1()
{
char buffer[100];
Foo::Test(buffer);
}char anotherBuffer \_\_nogc\[100\]; void TestFunc2() { Foo::Test(anotherBuffer); }
};
While there's no problem with
Bar::TestFunc1
,Bar::TestFunc2
won't compile. The error message is error C2664: cannot convert parameter 1 from 'char [100]' to 'char *'. The only difference is that in the first case the char array is allocated on the stack, while in the latter it's a member of the class.. However, if I change the call tovoid TestFunc2() { Foo::Test(&anotherBuffer\[0\]); }
, I get the message error C2664: cannot convert parameter 1 from 'char __gc *' to 'char *'. Any help is appreciated. Regards Thomas
Disclaimer:
Because of heavy processing requirements, we are currently using some of your unused brain capacity for backup processing. Please ignore any hallucinations, voices or unusual dreams you may experience. Please avoid concentration-intensive tasks until further notice. Thank you.