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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?bGlnaHRkb2xs?=

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

    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)(in t nCount, exchagned stIndex[]);// callback
    function.

    static void NotifyToC(Syste m::Object ^sender, Dictionary<int, _CRequested^>
    ^requested)
    {
    int nLength = requestedIndex->Count;
    array<exchagned *>^ arrIndex = gcnew array<exchagned ; *>(nLength);
    int nCount = 0;
    _CRequested^ requested;
    for each(KeyValuePa ir<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<exchagn ed*p1 = &arrIndex[0]; --

    |-here is my problem.
    // gCallBackofExch anged(nCount, arrIndex);--
    }

    so how can i solve this problem.

    could you help me...

    ^^


  • =?UTF-8?B?QXJuZSBWYWpow7hq?=

    #2
    Re: how to exchange a structure between c++/cli and c, c++

    lightdoll wrote:
    i couldn't find out a board about c++/cli from ,
    You could try microsoft.publi c.dotnet.langua ges.vc, but we do
    have a few C++/CLI experts hanging out here as well.

    Arne

    Comment

    Working...