Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / July 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Joseph Lu - 17 Jul 2006 07:24 GMT
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_threadnum++)
{
 AfxBeginThread(ReadDatFile(i_threadnum),GetSafeHwnd(),THREAD_PRIORITY_NORMAL);
}
}
//------------------------------
Could anybody tell me why? Thanks in advance!

Joseph
Bruno van Dooren [MVP VC++] - 17 Jul 2006 09:31 GMT
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
[quoted text clipped - 6 lines]
> return 0;
> }

This is not the correct function signature for a thread function.
Check MSDN.

> // CReadDatFilesView ÏûÏ¢´¦Àí³ÌÐò
>
[quoted text clipped - 9 lines]
> }
> }

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.

Signature

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

Michael Buechel - 17 Jul 2006 13:35 GMT
> //-----------------------------
> UINT ReadDatFile(int i_thread)
> {
> AfxMessageBox(i_thread);
                   ^---- This should be a resource ID or a text

Signature

Kind regards, Michael Buechel

while(!sleep())
  sheeps++;

> First of all, when posting questions like this, you should identify the
> exact line that triggers the error, and the complete error message.
[quoted text clipped - 36 lines]
> parameter of AfxBeginThread as a parameter when it is executed.
> Read the documentation for AfxBeginThread for more information.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.