Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. error c2071: illegal storage class

error c2071: illegal storage class

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jawadali477
    wrote on last edited by
    #1

    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

    P 1 Reply Last reply
    0
    • J jawadali477

      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

      P Offline
      P Offline
      Peter_in_2780
      wrote on last edited by
      #2

      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 like

      CvMouseCallback 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. Peter

      Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012

      J 1 Reply Last reply
      0
      • P Peter_in_2780

        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 like

        CvMouseCallback 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. Peter

        Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012

        J Offline
        J Offline
        jawadali477
        wrote on last edited by
        #3

        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);

        P 1 Reply Last reply
        0
        • J jawadali477

          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);

          P Offline
          P Offline
          Parthi_Appu
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups