My code :

int _tmain(int argc, _TCHAR* argv[])
{
	HINTERNET hInternet;
	BOOL bResult;
	
	hInternet = InternetOpen(	(LPCTSTR)	"NoAgent",
								(DWORD)		INTERNET_OPEN_TYPE_DIRECT,
								(LPCTSTR)	NULL,
								(LPCTSTR)	NULL,
								(DWORD)		INTERNET_FLAG_ASYNC);
	if (hInternet == NULL)
	{
		DebugTest("hInternet == NULL");
	}
	
	DebugTest("Internet handle created!");
	
	bResult = InternetCloseHandle((HINTERNET) hInternet);
	if (bResult == NULL)
	{
		DebugTest("InternetCloseHandle((HINTERNET) hInternet) == NULL");
	}
	
	
	
	return 0;
}

Here is how DebugTest() defined :

VOID DebugTest(CHAR * lpzsErrorText)
{
	if (MessageBox(NULL, lpzsErrorText, "Error", MB_ICONERROR | MB_OKCANCEL)==IDCANCEL)
	{
	}
}
VOID DebugTest(INT nText)	//Overloaded
{
	CHAR lpzsErrorText[32];
	_itoa(nText, lpzsErrorText, 10);
	if (MessageBox(NULL, lpzsErrorText, "Error", MB_ICONERROR | MB_OKCANCEL)==IDCANCEL)
	{
	}
}

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 = ?

Recommended Answers

All 3 Replies

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...

Is it the complete code? or somthing else is also there.

> 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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.