Several Threads. Help me 
Author Message
 Several Threads. Help me

I have a problem. I want to create several threads in a program. I have
a Process that define a statechart. I want to create several statechart,
runing together. I use the sentence "_beginthead" and I have a error. I
ask for the problem:

" : error C2664: '_beginthread' : cannot convert parameter 1 from
'void
 (int *)' to 'void (__cdecl *)(void *)'

 The sentence is:         _beginthread(Process,0,( int *)(ch));

 and Process is defined:        void Process(int *ch);"

all is defined in the same program 'InternasDlg.cpp'

and thereply was

You are attempting to pass a pointer to member function to
beginthread.  This doesn't work because pointers to member functions
are not the same thing as pointers to functions.

But I don't understand that I have to do.
Sorry, because my english isn't very good.

         Thanks,  Javi



Fri, 28 Jun 2002 03:00:00 GMT  
 Several Threads. Help me
Ok, let's start from the beginning.
Once upon a time there were dinosaures.....
Well, no, just kidding ;-)

the error tels you:
you gave me a 'void (int*)' parameter but I want a 'void (__cdecl*)(void*)'
parameter.

It means that you declared your function as you stated:
void MyThreadFunction(int *ch);

but it *has* to be:
void __cdecl MyThreadFunction(void* ch);    // __cdecl added and int* became
void*

Can you feel the difference ?
If in your code you want to use an int* ch then do the following:

void __cdecl MyThreadFunction(void* ch2)
{
    int* ch = (int*)ch2;
    // do what you want now with ch

Quote:
}

HTH
Guillaume.
Quote:

>I have a problem. I want to create several threads in a program. I have
>a Process that define a statechart. I want to create several statechart,
>runing together. I use the sentence "_beginthead" and I have a error. I
>ask for the problem:

>" : error C2664: '_beginthread' : cannot convert parameter 1 from
>'void
> (int *)' to 'void (__cdecl *)(void *)'

> The sentence is:         _beginthread(Process,0,( int *)(ch));

> and Process is defined:        void Process(int *ch);"

>all is defined in the same program 'InternasDlg.cpp'

>and thereply was

>You are attempting to pass a pointer to member function to
>beginthread.  This doesn't work because pointers to member functions
>are not the same thing as pointers to functions.

>But I don't understand that I have to do.
>Sorry, because my english isn't very good.

>         Thanks,  Javi



Fri, 28 Jun 2002 03:00:00 GMT  
 Several Threads. Help me
Oups.. forgot to mension that the function should be also declared as static
in the class.

Guillaume.

Quote:

>Ok, let's start from the beginning.
>Once upon a time there were dinosaures.....
>Well, no, just kidding ;-)

>the error tels you:
>you gave me a 'void (int*)' parameter but I want a 'void (__cdecl*)(void*)'
>parameter.

>It means that you declared your function as you stated:
>void MyThreadFunction(int *ch);

>but it *has* to be:
>void __cdecl MyThreadFunction(void* ch);    // __cdecl added and int*
became
>void*

>Can you feel the difference ?
>If in your code you want to use an int* ch then do the following:

>void __cdecl MyThreadFunction(void* ch2)
>{
>    int* ch = (int*)ch2;
>    // do what you want now with ch
>}

>HTH
>Guillaume.


>>I have a problem. I want to create several threads in a program. I have
>>a Process that define a statechart. I want to create several statechart,
>>runing together. I use the sentence "_beginthead" and I have a error. I
>>ask for the problem:

>>" : error C2664: '_beginthread' : cannot convert parameter 1 from
>>'void
>> (int *)' to 'void (__cdecl *)(void *)'

>> The sentence is:         _beginthread(Process,0,( int *)(ch));

>> and Process is defined:        void Process(int *ch);"

>>all is defined in the same program 'InternasDlg.cpp'

>>and thereply was

>>You are attempting to pass a pointer to member function to
>>beginthread.  This doesn't work because pointers to member functions
>>are not the same thing as pointers to functions.

>>But I don't understand that I have to do.
>>Sorry, because my english isn't very good.

>>         Thanks,  Javi



Fri, 28 Jun 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Several threads, help

2. Sorry.Several Threads

3. Several Threads in one Process

4. executing function from several threads

5. a dll, several threads and one dialog...

6. a dll, several threads and one dialog...

7. several doc/views + threads

8. Several bugs, spanning several products (VS.Net, OfficeXP)

9. Using one header file for several source files - help please

10. Need help with several .c files

11. Help on opening several files at the same time

12. Several questions, please help!

 

 
Powered by phpBB® Forum Software