DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2
  1. #1
    Join Date
    May 2004

    Smile Problem using member function when dealing with threading

    :) hi, i am new in programming and now dealing with some multi threading stuff

    anyway i got problem when trying to use member function when doing threads

    i searched around the net and found that 1 method is by using messages which is rather complex

    another method that somebody posted is by casting:

    DWORD pg_control::thr ( LPVOID lpvParam ) // static
        pg_control *thr = (pg_control*)lpvParam;
        // Go on with code ...
        return 0;
    void pg_control::OnNn()
       AfxBeginThread (   (AFX_THREADPROC)pg_control::thr,  (LPVOID)this );}

    however i get some errors

    C:\Program Files\Microsoft Visual Studio\MyProjects\abc.cpp(222) : error C2440: 'type cast' : cannot convert from '' to 'unsigned int (__cdecl *)(void *)'
    None of the functions with this name in scope match the target type
    Error executing cl.exe.

    AClient.exe - 1 error(s), 0 warning(s)

    the problem lies in the red text
    can anyone please correct and enlighten me?

    - using winxp programming for win98se
    - MFC style
    - VC++6.0 SP6 :)

  2. #2
    Join Date
    Nov 2003
    First of all, you need to add the & operator before pg_control::thr:

    Secondly, you're using thr both as a function's name and as a local variable. This might confuse the compiler (especially if it's an older one, such as VC++). Finally, make sure that pg_control::thr is a static function. The comment says that it is, but it's worth checking pg_control.h again.
    Danny Kalev

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.