472,097 Members | 1,104 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,097 software developers and data experts.

error C2665 :none of the number1 overloads can convert parameter number2 from type 'type'

Hi, I have a multithread problem like the following lines, when I compile
this code I caught a "error C2665", the error description is : none of the
number1 overloads can convert parameter number2 from type 'type'

//-----------------------------
UINT ReadDatFile(int i_thread)
{
AfxMessageBox(i_thread);
return 0;
}

// CReadDatFilesView ÏûÏ¢´¦Àí³ÌÐò

void CReadDatFilesView::OnBnClickedReadfile()
{
// TODO: ÔÚ´ËÌí¼Ó¿Ø¼þ֪ͨ´¦Àí³ÌÐò´úÂë
UpdateData();
int i_threadnum;
for(i_threadnum=1;i_threadnum<=m_maxthreadnum;i_th readnum++)
{
AfxBeginThread(ReadDatFile(i_threadnum),GetSafeHwn d(),THREAD_PRIORITY_NORMAL);
}
}
//------------------------------
Could anybody tell me why? Thanks in advance!

Joseph
Jul 17 '06 #1
2 5610
First of all, when posting questions like this, you should identify the
exact line that triggers the error, and the complete error message.
Otherwise we have to read through all of the code, trying to figure out
which line it might be.
Hi, I have a multithread problem like the following lines, when I compile
this code I caught a "error C2665", the error description is : none of
the number1 overloads can convert parameter number2 from type 'type'

//-----------------------------
UINT ReadDatFile(int i_thread)
{
AfxMessageBox(i_thread);
return 0;
}
This is not the correct function signature for a thread function.
Check MSDN.
>
// CReadDatFilesView ÏûÏ¢´¦Àí³ÌÐò

void CReadDatFilesView::OnBnClickedReadfile()
{
// TODO: ÔÚ´ËÌí¼Ó¿Ø¼þ֪ͨ´¦Àí³ÌÐò´úÂë
UpdateData();
int i_threadnum;
for(i_threadnum=1;i_threadnum<=m_maxthreadnum;i_th readnum++)
{

AfxBeginThread(ReadDatFile(i_threadnum),GetSafeHwn d(),THREAD_PRIORITY_NORMAL);
}
}
You supply the wrong arguments.
The first parameter should be the function pointer only.
You try to supply a function pointer together with the function argument.

If your function has the correct signature, it will receive the 2nd
parameter of AfxBeginThread as a parameter when it is executed.
Read the documentation for AfxBeginThread for more information.

--

Kind regards,
Bruno van Dooren
br**********************@hotmail.com
Remove only "_nos_pam"
Jul 17 '06 #2
>
//-----------------------------
UINT ReadDatFile(int i_thread)
{
AfxMessageBox(i_thread);
^---- This should be a resource ID or a text
--
Kind regards, Michael Buechel

while(!sleep())
sheeps++;

"Bruno van Dooren [MVP VC++]" <br**********************@hotmail.comschrieb
im Newsbeitrag news:eZ**************@TK2MSFTNGP04.phx.gbl...
First of all, when posting questions like this, you should identify the
exact line that triggers the error, and the complete error message.
Otherwise we have to read through all of the code, trying to figure out
which line it might be.
>Hi, I have a multithread problem like the following lines, when I compile
this code I caught a "error C2665", the error description is : none of
the number1 overloads can convert parameter number2 from type 'type'

//-----------------------------
UINT ReadDatFile(int i_thread)
{
AfxMessageBox(i_thread);
return 0;
}

This is not the correct function signature for a thread function.
Check MSDN.
>>
// CReadDatFilesView ÏûÏ¢´¦Àí³ÌÐò

void CReadDatFilesView::OnBnClickedReadfile()
{
// TODO: ÔÚ´ËÌí¼Ó¿Ø¼þ֪ͨ´¦Àí³ÌÐò´úÂë
UpdateData();
int i_threadnum;
for(i_threadnum=1;i_threadnum<=m_maxthreadnum;i_t hreadnum++)
{

AfxBeginThread(ReadDatFile(i_threadnum),GetSafeHw nd(),THREAD_PRIORITY_NORMAL);
}
}

You supply the wrong arguments.
The first parameter should be the function pointer only.
You try to supply a function pointer together with the function argument.

If your function has the correct signature, it will receive the 2nd
parameter of AfxBeginThread as a parameter when it is executed.
Read the documentation for AfxBeginThread for more information.

--

Kind regards,
Bruno van Dooren
br**********************@hotmail.com
Remove only "_nos_pam"

Jul 17 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Peter Frost | last post: by
2 posts views Thread by Hendrik Schober | last post: by
5 posts views Thread by Gang Zhang | last post: by
Schwack
2 posts views Thread by Schwack | last post: by
kiseitai2
10 posts views Thread by kiseitai2 | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.