"already defined" error

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2005
Posts: 71
Reputation: AhmedHan is an unknown quantity at this point 
Solved Threads: 1
AhmedHan's Avatar
AhmedHan AhmedHan is offline Offline
Junior Poster in Training

"already defined" error

 
0
  #1
Apr 18th, 2006
My code :
  1. int _tmain(int argc, _TCHAR* argv[])
  2. {
  3. HINTERNET hInternet;
  4. BOOL bResult;
  5.  
  6. hInternet = InternetOpen( (LPCTSTR) "NoAgent",
  7. (DWORD) INTERNET_OPEN_TYPE_DIRECT,
  8. (LPCTSTR) NULL,
  9. (LPCTSTR) NULL,
  10. (DWORD) INTERNET_FLAG_ASYNC);
  11. if (hInternet == NULL)
  12. {
  13. DebugTest("hInternet == NULL");
  14. }
  15.  
  16. DebugTest("Internet handle created!");
  17.  
  18. bResult = InternetCloseHandle((HINTERNET) hInternet);
  19. if (bResult == NULL)
  20. {
  21. DebugTest("InternetCloseHandle((HINTERNET) hInternet) == NULL");
  22. }
  23.  
  24.  
  25.  
  26. return 0;
  27. }

Here is how DebugTest() defined :
  1. VOID DebugTest(CHAR * lpzsErrorText)
  2. {
  3. if (MessageBox(NULL, lpzsErrorText, "Error", MB_ICONERROR | MB_OKCANCEL)==IDCANCEL)
  4. {
  5. }
  6. }
  7. VOID DebugTest(INT nText) //Overloaded
  8. {
  9. CHAR lpzsErrorText[32];
  10. _itoa(nText, lpzsErrorText, 10);
  11. if (MessageBox(NULL, lpzsErrorText, "Error", MB_ICONERROR | MB_OKCANCEL)==IDCANCEL)
  12. {
  13. }
  14. }

The error given :
------ Build started: Project: Internet, Configuration: Debug Win32 ------
Compiling...
Internet.cpp
Linking...
stdafx.obj : error LNK2005: "void __cdecl DebugTest(char *)" (?DebugTest@@YAXPAD@Z) already defined in Internet.obj
C:\Documents and Settings\Ahmed Han\Belgelerim\Visual Studio 2005\Projects\Internet\Debug\Internet.exe : fatal error LNK1169: one or more multiply defined symbols found
Build log was saved at "file://c:\Documents and Settings\Ahmed Han\Belgelerim\Visual Studio 2005\Projects\Internet\Debug\BuildLog.htm"
Internet - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I used the same code for some of my other programs too, but this is the first time it gives such an error.

Platform : WinXP Home
Compiler : VC++ 2005
Reason for error = ?
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1,496
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Solved Threads: 104
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: "already defined" error

 
0
  #2
Apr 18th, 2006
Nothing seems to be wrong at first glance. Maybe there is a semicolon out of place in a header file or any other source file where DebugTest is declared. That is the most possible cause that comes to my mind...
バルサミコ酢やっぱいらへんで
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 176
Reputation: dubeyprateek is an unknown quantity at this point 
Solved Threads: 22
dubeyprateek's Avatar
dubeyprateek dubeyprateek is offline Offline
Junior Poster

Re: "already defined" error

 
0
  #3
Apr 20th, 2006
Is it the complete code? or somthing else is also there.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: "already defined" error

 
0
  #4
Apr 20th, 2006
> stdafx.obj : error LNK2005: "void __cdecl DebugTest(char *)" (?DebugTest@@YAXPAD@Z) already defined in Internet.obj
This is what you normally get when you #include one .cpp file inside another, or put actual code (not declarations) inside header files.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC