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
2 Posts 2 Posters 2 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 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.

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

      Make the function run() a static member of the CClass. Or make it a global function. If you want to execute a member function as thread, it should be either a static member function or a global function.

      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