how to exchange a structure between c++/cli and c, c++

L

lightdoll

hello everyone.

i couldn't find out a board about c++/cli from , so i wrote my problem
writing a code with c++/cli.

i have made a dll of c++/cli, then i want to exchange structure between
c++/cli and c.

this is the structure
typedef struct tagExchange
{
int m_nIndex;
float m_fValue;
} exchagned;

first , c will use the dll made by c++/cli.
then c will pass a function pointer to c++/cli like callback function.
because i want to use the callback like event.

typedef void (*EXCHANGED)(int nCount, exchagned stIndex[]);// callback
function.

static void NotifyToC(System::Object ^sender, Dictionary<int, _CRequested^>
^requested)
{
int nLength = requestedIndex->Count;
array<exchagned *>^ arrIndex = gcnew array<exchagned; *>(nLength);
int nCount = 0;
_CRequested^ requested;
for each(KeyValuePair<int, _CRequested^>^ pair in requested)
{
arrIndex[nCount] = new exchagned();
arrIndex[nCount]->m_nIndex = pair->Key;
requestedItem =(_CRequested^) pair->Value;
arrIndex[nCount]->m_fValue =requestedItem->m_fValue;
nCount++;
}
pin_ptr<exchagned*> p1 = &arrIndex[0]; --

|-> here is my problem.
// gCallBackofExchanged(nCount, arrIndex);--
}

so how can i solve this problem.

could you help me...

^^
 
A

Arne Vajhøj

lightdoll said:
i couldn't find out a board about c++/cli from ,

You could try microsoft.public.dotnet.languages.vc, but we do
have a few C++/CLI experts hanging out here as well.

Arne
 

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