0

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.

ravenspoint
  • 19,093
  • 6
  • 57
  • 103
Btc Sources
  • 1,912
  • 2
  • 30
  • 58
  • The error message would be more clear if it had the word "or" between the two parts. You have to prepend & to the name, to avoid confusion with a function call missing arguments. – Stein Jun 17 '15 at 11:25
  • If I write `&FrameDoneCallback ` the error changes to `error C2276: '&' : operación no válida de la expresión de función miembro enlazada` (`'operator' : illegal operation on bound member function expression`) @Stein – Btc Sources Jun 17 '15 at 11:29
  • It's from `VimbaC.h` @ravenspoint, it's defined like: `#define VMB_CALL __stdcall`. These are stuff from the API I've no modified at all. – Btc Sources Jun 17 '15 at 12:10
  • Surely it needs a function pointer to an *unmanaged* function. Your FrameDoneCallback() function doesn't look like one when it is a member of the Form1 class. Use Marshal::GetFunctionPointerForDelegate() if necessary. – Hans Passant Jun 17 '15 at 12:19
  • I'm using C++/CLI, since I'm in a Visual C++ Project using winform @ravenspoint – Btc Sources Jun 17 '15 at 12:27
  • I think I know now how it works. The point is what @ravenspoint said. My mate has the callback defined outside the class, using a lot of global variables to store data from the processing callback, then using a backgroundworker + delegates to update the GUI using it. – Btc Sources Jun 17 '15 at 12:50

1 Answers1

0

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.

ravenspoint
  • 19,093
  • 6
  • 57
  • 103
  • It seems like moving the callback function outside the class to the namespace fix the problem, but the problem is that the callback function uses another class functions and controls from the form, so it's not runnable just like that. Would have to think about how to modify it in order to access these controls and functions (cannot take out the functions neither cause they access some controls from the form too). – Btc Sources Jun 17 '15 at 12:20