Click to See Complete Forum and Search --> : Threads


roadragedave
April 29th, 2004, 07:52 AM
All I want to do is have a while loop repeating untill a key-stroke is hit, I got this code off the MSDN
(BeginThread Example) (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt__beginthread.2c_._beginthreadex.asp) and it works when I build a project on its own.

I tried to add some of the code to my own proj like so:


void CheckKey( void *dummy );
BOOL repeat = TRUE;

void main(void)
{
......
......
_beginthread(CheckKey, 0, NULL);
while(repeat)
{
......
......
}
}
//seperate thread that waits for a key-stroke
void CheckKey( void *dummy )
{
_getch();
repeat = 0; /* _endthread implied */
}



but then I get this error:


error C3861: '_beginthread': identifier not found, even with argument-dependent lookup


I have included process.h, am I missing a lib file or something????:confused:

Ness
May 8th, 2004, 08:41 PM
Make sure you used the right namespace.

JasonD
May 18th, 2004, 01:13 PM
Are you compiling with multi-threaded libraries?

IsaacTheIceMan
October 15th, 2004, 06:28 AM
VS .NET:
To build a multithread application you must tell the compiler to use a special version of the libraries (LIBCMT.LIB). To select these libraries, first open the project's Property Pages dialog box (View menu) and click the C/C++ folder. Select the Code Generation page. From the Runtime Library drop-down box, select Multi-threaded. Click OK to return to editing.

or add /MT to the command line of your compiler.