Simple Types and Marshalling Question

G

Guest

Greetings,

When working with managed c++, do you have to do anything special when going
from simple types from managed to unmanaged and vice versa. Or is
marshalling handled automatically for you?
I have seen from several posts that you have to do special conversions for
strings, but what about the other types such as int, long,ect. In my case I
want to save it as a member variable from a managed class into an unmanaged
class's.

(ie:)
// Managed function calls a pointer to a unmanaged class's function.
void TestNum(int newNum)
{
// Call unmanaged class's function.
pMyUnmanagedClass->UpdateNewNum(newNum);
}

void CMyUnmanagedClass::UpdateNewNum(int nNumber)
{
// Do I have to do anything special here????
// Or is this handled through the marshalling?
m_nMemberTest = nNumber;
}


Thanks in advance!
 
C

Carl Daniel [VC++ MVP]

BartMan said:
Greetings,

When working with managed c++, do you have to do anything special
when going from simple types from managed to unmanaged and vice
versa. Or is marshalling handled automatically for you?
I have seen from several posts that you have to do special
conversions for strings, but what about the other types such as int,
long,ect. In my case I want to save it as a member variable from a
managed class into an unmanaged class's.

(ie:)
// Managed function calls a pointer to a unmanaged class's function.
void TestNum(int newNum)
{
// Call unmanaged class's function.
pMyUnmanagedClass->UpdateNewNum(newNum);
}

void CMyUnmanagedClass::UpdateNewNum(int nNumber)
{
// Do I have to do anything special here????
// Or is this handled through the marshalling?
m_nMemberTest = nNumber;
}

built-in scalar types char, byte, int, short, long, __int64, double, float
(etc) are all mapped directly across and can simply be copied between
managed and unmanaged.

-cd
 
G

Guest

Thanks! That makes sense.

Carl Daniel said:
built-in scalar types char, byte, int, short, long, __int64, double, float
(etc) are all mapped directly across and can simply be copied between
managed and unmanaged.

-cd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top