error c2071: illegal storage class
-
hi, i'm using opencv with mfc for image processing and getting this error, "error c2071 : 'CvMouseCallback' illegal storage class", which i don't understand why. the code giving this error is:
typedef void CvMouseCallback( int CV_EVENT_LBUTTONDBCLK, int x, int y, int flags, void* param )
{
//do some stuff here
}and it has been defined in header file as
typedef void (CV_CDECL *CvMouseCallback )(int event, int x, int y, int flags, void* param);
can someone help me. Regards -J
-
hi, i'm using opencv with mfc for image processing and getting this error, "error c2071 : 'CvMouseCallback' illegal storage class", which i don't understand why. the code giving this error is:
typedef void CvMouseCallback( int CV_EVENT_LBUTTONDBCLK, int x, int y, int flags, void* param )
{
//do some stuff here
}and it has been defined in header file as
typedef void (CV_CDECL *CvMouseCallback )(int event, int x, int y, int flags, void* param);
can someone help me. Regards -J
jawadali477 wrote:
typedef void CvMouseCallback( int CV_EVENT_LBUTTONDBCLK, int x, int y, int flags, void* param ) { //do some stuff here }
When you are defining (writing the code of) your function to handle the callback, you don't want
typedef
, and you want to USE the typedef from the header file. So what you want is something likeCvMouseCallback my_callback_function(int event, int x, int y, int flags, void *param)
{
// do stuff
}Also, you don't want the constant
CV_EVENT_LBUTTONDBCLK
in your function definition. PeterSoftware rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
-
jawadali477 wrote:
typedef void CvMouseCallback( int CV_EVENT_LBUTTONDBCLK, int x, int y, int flags, void* param ) { //do some stuff here }
When you are defining (writing the code of) your function to handle the callback, you don't want
typedef
, and you want to USE the typedef from the header file. So what you want is something likeCvMouseCallback my_callback_function(int event, int x, int y, int flags, void *param)
{
// do stuff
}Also, you don't want the constant
CV_EVENT_LBUTTONDBCLK
in your function definition. PeterSoftware rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
thank you Peter for your reply. i did modified the code as you suggested but now i'm having this errors
error C2660: 'SetDlgItemTextW' : function does not take 2 arguments
error C2660: 'SetDlgItemTextW' : function does not take 2 arguments
error C2660: 'SetDlgItemTextW' : function does not take 2 arguments
error C2664: 'cvSetMouseCallback' : cannot convert parameter 2 from 'CvMouseCallback (__cdecl *)(int,int,int,int,void *)' to 'CvMouseCallback'the lines that are giving this errors are
CvMouseCallback on_mouse( int event, int x, int y, int flags, void* param )
{
//SetDlgItemText(IDC_Blue, (LPCTSTR) L"ok");
CvScalar s;
CString Blue, Green, Red;
IplImage* zoomed = (IplImage*) param;s=cvGet2D(zoomed,x,y); // get the (x,y) pixel value Blue.Format(\_T("%0.2f"), s.val\[0\]); Green.Format(\_T("%0.2f"), s.val\[1\]); Red.Format(\_T("%0.2f"), s.val\[2\]); SetDlgItemText(IDC\_Blue, Blue); //error C2660 SetDlgItemText(IDC\_Green, Green); //error C2660 SetDlgItemText(IDC\_Red, Red); //error C2660
}
cvSetMouseCallback("box.png", on_mouse, (void*) zoomed) //error C2664
(defined some other place); -
thank you Peter for your reply. i did modified the code as you suggested but now i'm having this errors
error C2660: 'SetDlgItemTextW' : function does not take 2 arguments
error C2660: 'SetDlgItemTextW' : function does not take 2 arguments
error C2660: 'SetDlgItemTextW' : function does not take 2 arguments
error C2664: 'cvSetMouseCallback' : cannot convert parameter 2 from 'CvMouseCallback (__cdecl *)(int,int,int,int,void *)' to 'CvMouseCallback'the lines that are giving this errors are
CvMouseCallback on_mouse( int event, int x, int y, int flags, void* param )
{
//SetDlgItemText(IDC_Blue, (LPCTSTR) L"ok");
CvScalar s;
CString Blue, Green, Red;
IplImage* zoomed = (IplImage*) param;s=cvGet2D(zoomed,x,y); // get the (x,y) pixel value Blue.Format(\_T("%0.2f"), s.val\[0\]); Green.Format(\_T("%0.2f"), s.val\[1\]); Red.Format(\_T("%0.2f"), s.val\[2\]); SetDlgItemText(IDC\_Blue, Blue); //error C2660 SetDlgItemText(IDC\_Green, Green); //error C2660 SetDlgItemText(IDC\_Red, Red); //error C2660
}
cvSetMouseCallback("box.png", on_mouse, (void*) zoomed) //error C2664
(defined some other place);First regarding error C2660, who have used the MFC version of SetDlgItemText, which is a wrapper for Win32 API. If your function is a member of dialog class then the handle to the dialog is passes as a first param. So to get rid of C2660 pass the handle of the dialog as first param and then pass the next two params. And regarding C2664 the declaration is incorrect. Your callback function should return void with calling convention as CV_CDECL (or equivalent basic calling conevention, check this in your code)
Do your Duty and Don't Worry about the Result