Hi, I'm creating my own text editor to put into practice what I know about the Win32 API. I'm working on a class to manage the Rich Edit control, and I've just made a class and a function for debug puposes to notify me when errors come up with a bit of information about the error.
I'm using Visual C++ .NET 2003 Standard and when I try to compile & link my project, I get the following error:
Code:
Notepad error LNK2005: "void __cdecl ShowError(struct SError &)" (?ShowError@@YAXAAUSError@@@Z) already defined in main.obj
I know what this error means, but unfortunately I'm very confused as to what is causing this error... I'm sure I'm including my headers in the correct order... Here is the order in which my functions are being included in my project:
Code:
Error.h
/
/
CSearch.h CFileManager.h
/ \ / \
/ \ / \
/ \ / \
CSeach.cpp CTextManager.h CFileManager.cpp
/ \
/ \
/ \
main.cpp CTextManager.cpp
And here is Error.h (where ShowError() is defined)
Code:
#ifndef ERROR_H
#define ERROR_H
#include <string>
struct SError
{
SError(char *szFunction, char *szError, char *szDescription)
{
m_szFunction = szFunction;
m_szError = szError;
m_szDescription = szDescription;
}
std::string m_szFunction; // Function where error occured
std::string m_szError; // Error title
std::string m_szDescription; // Error description
};
void ShowError(SError &error)
{
// Format error string
std::string szBuffer;
szBuffer = "Error in Function: \"";
szBuffer += error.m_szFunction;
szBuffer += "\"\n";
szBuffer += "Error: ";
szBuffer += error.m_szError;
szBuffer += "\nDetail: ";
szBuffer += error.m_szDescription;
// Show error
MessageBox(0, szBuffer.data(), "Error!", MB_ICONERROR);
}
#endif
Perhaps I am just overlooking something, or am just doing something wrong. But I'd be grateful if someone could help resolve this error for me, I dont get this error very often as I haven't really taken on any projects of this size...