Using C callback in C++/CLI

305 views Asked by At

What I have

I'm using Vimba C API, in my C++/CLI application. It's known to work since my mate has it done and running without errors.

I've all the imports/include done. I'm using the API without errors, except one.

The Manual Says

In the manual of the API, there's some example of how to capture an image with the camera. To be precise, the callback function which is run when a capture is completed is:

// The callback that gets executed on every filled frame
9  void VMB_CALL FrameDoneCallback( const VmbHandle_t hCamera , VmbFrame_t     *pFrame )
10 {
11     if ( VmbFrameStatusComplete == pFrame ->receiveStatus )
12     {
13         std::cout << "Frame successfully received" << std::endl;
14     }
15     else
16     {
17         std::cout << "Error receiving frame" << std::endl;
18     }
19 VmbCaptureFrameQueue( hCamera , pFrame , FrameDoneCallback );
20 }

The Error

I've used it exactly the same way (even more, It's from the manual, but it's the same as my work mate, I've copied his code which is known to work) (my line):

VmbCaptureFrameQueue( hCamera, &frameAsinc,  FrameDoneCallback );

However, when I build the app, I get:

Error   4   error C3867: 'Granja::Form1::FrameDoneCallback': falta la lista de argumentos de la llamada a la funciĆ³n; utilice '&Granja::Form1::FrameDoneCallback' para crear un puntero al miembro

Which says is needed an arguments list to call the function. Use &... to create a pointer to the member.

But this makes no sense for me, since a callback needs a pointer to a function, so it needs just the name of the method, not the arguments (plus, again, my mate has it working doing it that way, as the manual says).

Any idea or guidance about this?

Thank you in advance

PS: I'm not sure if the tags are the most appropriate, please edit if you consider it would be better ones, thanks.

1

There are 1 answers

1
ravenspoint On BEST ANSWER

illegal operation on bound member function expression

This looks like you are attempting to callback a class member function. It can be done, but is a little tricky. You are best to callback a free global function, get it working, then look into how to call back a class member function.

Is the code you have posted the actual code that is generating the error? It seems like it might be the code from the API manual. or from your mates code. You need to let us look at the code that is actually causing the problem.