Board index » cppbuilder » _beginthread vs _beginthreadNT??? How do I point to my routine void poll_input_available()???

_beginthread vs _beginthreadNT??? How do I point to my routine void poll_input_available()???


2005-09-16 05:47:43 AM
cppbuilder75
void poll_input_available()
{
int now_place;
int end_place;
now_place = fseek(stdin, 0, 1);
end_place = fseek(stdin, 0, 2);
if (now_place == end_place)
{
input_is_available = false; // a global var
}
else
{
input_is_available = true; // a global var
}
}
bool my_file_read_line(FILE * file, char string[], int size)
{
int thread_id;
void * arglist;
if ((thread_id = _beginthread(_USERENTRY &poll_input_available(),
4096, arglist)) == -1)
{
printf("Unable to create thread, errno = %d\n", errno);
_endthread();
return false;
}
else
{
_endthread();
}
if (!input_is_available) return false;
fgets... and the completion of this routine.
------------------------------------------------------------
and do i need _beginthreadNT for Windows XP?
Bill Mowery Jr MSEE
 
 

Re:_beginthread vs _beginthreadNT??? How do I point to my routine void poll_input_available()???

"w h mowery jr" < XXXX@XXXXX.COM >wrote in message
Quote
if ((thread_id = _beginthread(_USERENTRY &poll_input_available(),
4096, arglist)) == -1)
That is not the correct way to pass a function pointer as a parameter.
Specify *only* the function's name, ie:
if ((thread_id = _beginthread(poll_input_available, 4096, arglist))
== -1)
Or optionally use the '&' operator:
if ((thread_id = _beginthread(&poll_input_available, 4096, arglist))
== -1)
You also need to apply _USERENTRY to the function itself, not when passing
it as a parameter:
void _USERENTRY poll_input_available()
{
//...
}
Gambit