Jump to content

Can someone help me with an example for an existing wrapper DLL which uses function pointer with callback function

Recommended Posts

2 hours ago, Neon_Light said:

So I can give the adres of handle to testDataBlock.dataRecords, like this:


and thats it ? 


when I try the code above I get:

a value of type "DataArrayHdl*" cannot be assigned to an antity of type "DataArrayHdl"

in the line: 

testDataBlock.DataRecords = &handle;

Can anyone tell me what I might be doing wrong ?

Please, follow a C programming course first and work through it until you get to the advanced topics including memory pointers! This is not LabVIEW but C programming.

You are missing very fundamental pointer knowledge!

testDataBlock.DataRecords = (DataArrayHdl)handle;

Alternatively you can write the code directly like this.

    size_t len = offsetof(DataArrayRec, elms) + size * sizeof(DataRecord)
    if (!testDataBlock.dataRecords)
        testDataBlock.dataRecords = (DataArrayHdl)DSNewHandle(len);
        if (!testDataBlock.dataRecords)
            err = mFullErr;
        err = DSSetHandleSize((UHandle)testDataBlock.dataRecords, len);

And you need to do that every time again.

testDataBlock is on the stack, this stack gets invalidated every time you leave your function. That is why we do a DSDisposeHandle() before leaving the function, to deallocate the previously allocated handle before the stack is invalidated and the handle lost forever.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.