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. Other Discussions
  3. IT & Infrastructure
  4. _begintread() problem

_begintread() problem

Scheduled Pinned Locked Moved IT & Infrastructure
c++helpvisual-studioquestion
4 Posts 4 Posters 4 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    In my previous c program, i use _beginthread(run, 0, NULL) where run is void run(){ } and face no problem. However, when i try to port it to cpp program, i face some problem when my run is defined as void CClass::run(){ } where vs c++ compiler complaint "cannot convert from 'void(void) to 'void(_cdecl*)(void*)' Then I try to cast it by using _beginthread(((_cdecl *)(void *))run, 0, NULL) my vs c++ compiler still complaint that _cdecl is syntax error what should i do to overcome this problem? thank you.

    K M 2 Replies Last reply
    0
    • L Lost User

      In my previous c program, i use _beginthread(run, 0, NULL) where run is void run(){ } and face no problem. However, when i try to port it to cpp program, i face some problem when my run is defined as void CClass::run(){ } where vs c++ compiler complaint "cannot convert from 'void(void) to 'void(_cdecl*)(void*)' Then I try to cast it by using _beginthread(((_cdecl *)(void *))run, 0, NULL) my vs c++ compiler still complaint that _cdecl is syntax error what should i do to overcome this problem? thank you.

      K Offline
      K Offline
      KingsGambit
      wrote on last edited by
      #2

      Make the function run() a static member of CClass. Or make it a global function. The problem will be solved

      N 1 Reply Last reply
      0
      • K KingsGambit

        Make the function run() a static member of CClass. Or make it a global function. The problem will be solved

        N Offline
        N Offline
        Nemanja Trifunovic
        wrote on last edited by
        #3

        ... and also use _beginthreadex() instead of _beginthread(). It may save you from big headaches. I vote pro drink :beer:

        1 Reply Last reply
        0
        • L Lost User

          In my previous c program, i use _beginthread(run, 0, NULL) where run is void run(){ } and face no problem. However, when i try to port it to cpp program, i face some problem when my run is defined as void CClass::run(){ } where vs c++ compiler complaint "cannot convert from 'void(void) to 'void(_cdecl*)(void*)' Then I try to cast it by using _beginthread(((_cdecl *)(void *))run, 0, NULL) my vs c++ compiler still complaint that _cdecl is syntax error what should i do to overcome this problem? thank you.

          M Offline
          M Offline
          Michael Dunn
          wrote on last edited by
          #4

          Your question is answered in the VC forum FAQ. --Mike-- http://home.inreach.com/mdunn/ You are the weakest link, GOODBYE!

          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