Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Dominik_78

How to start a thread in Win32 C++

This topic is 5735 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, i read about the _beginThread function but I can't use it because I use c++ (or is there a way to use it anyway with a c++ function of my class?). how to start a thread using C++ ? EDIT: I do not want to use MFC - so please don't tell me this is the only way to go.... thank you [edited by - Dominik_78 on December 6, 2002 2:45:09 PM]

Share this post


Link to post
Share on other sites
Advertisement
d:\projects\maddogcombat\ssengine.cpp(42) : error C2664: ''_beginthread'' : cannot convert parameter 1 from ''void (void)'' to ''void (__cdecl *)(void *)''

what does this mean?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
It means you need to typecast the thing you are passing in to a void*

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
And yes, you can use beginthread with c++. Just read the doc, it tells you exactly what to do.

Share this post


Link to post
Share on other sites
then this comes up:

d:\projects\maddogcombat\ssengine.cpp(42) : error C2440: ''type cast'' : cannot convert from ''void (__thiscall CSSEngine::*)(void)'' to ''void *''

Share this post


Link to post
Share on other sites
i did as the doc told but the compiler error came up.

if i compile the example everything is ok.

and the only difference i see ic c <> c++

just because i am using classes?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
[url="http://www.experts-exchange.com/Programming/Programming_Platforms/Win_Prog/Q_10168718.html"]This might help...[/url]

Share this post


Link to post
Share on other sites
that is because of the API not because of the syntax. Its because you created a class reference as an entry point for a API. Which is not allowed in that context. You must make the entry point function static. Then you must Make any variables that it will use static also.


If you have read the K&R reference manual, in basic c this would be clear on c/c++ API or static variables.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
this might help also: http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_20117462.html

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!