943,748 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 8757
  • C++ RSS
Apr 18th, 2006
0

"already defined" error

Expand Post »
My code :
C++ Syntax (Toggle Plain Text)
  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 :
C++ Syntax (Toggle Plain Text)
  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 :
Quote ...
------ 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 = ?
Similar Threads
Reputation Points: 13
Solved Threads: 1
Junior Poster in Training
AhmedHan is offline Offline
71 posts
since Apr 2005
Apr 18th, 2006
0

Re: "already defined" error

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...
Moderator
Reputation Points: 572
Solved Threads: 115
Mentally Challenged Mod.
WolfPack is offline Offline
1,559 posts
since Jun 2005
Apr 20th, 2006
0

Re: "already defined" error

Is it the complete code? or somthing else is also there.
Reputation Points: 39
Solved Threads: 24
Junior Poster
dubeyprateek is offline Offline
176 posts
since Mar 2006
Apr 20th, 2006
0

Re: "already defined" error

> 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.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Need Help in Reading characters from a text file
Next Thread in C++ Forum Timeline: urgent help!!!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC