Hey,
I've got the usual Visual C++ MFC program going. It's got a main dialog, with two (not-main?) dialogs that are called with DoModal().
The thing is that those two dialogs need the same files, which have the same functions and classes.
Here's an example of what I mean
MyClass.cpp
Code:
#include <windows.h>
class MyClass
{
public:
int a;
int b;
char c;
};
Functions.cpp
Code:
void doSomething()
{
//code to do something in here
}
int DoSomethingAsWell ( int i )
{
//Do something here
}
And then the header for both of the *.cpp files that apply to the DoModal dialogs looks like this:
Code:
#include "MyClass.cpp"
#include "Functions.cpp"
MyClass mc;
This code results in a bunch of linker errors (LNK2005, and LNK1169 for the last error). It's telling me the functions already exist in the other dialogs .obj file, however, if I don't include the file in the *.cpp file, it says that the functions/classes don't exist. So, it's either it doesn't exist, or it's already been defined!
Here's the actual link error:
Originally Posted by
Micro$oft
1>MacroCfgDlg.obj : error LNK2005: "class ATL::CStringT<wchar_t,class StrTraitMFC<wchar_t,class ATL::ChTraitsCRT<wchar_t> > > __cdecl to_vkey(int)" (?to_vkey@@YA?AV?$CStringT@_WV?$StrTraitMFC@_WV?$C hTraitsCRT@_W@ATL@@@@@ATL@@H@Z) already defined in AntiRecoilCfgDlg.obj
1>MacroCfgDlg.obj : error LNK2005: "unsigned long __stdcall getkey(void *)" (?getkey@@YGKPAX@Z) already defined in AntiRecoilCfgDlg.obj
1>MacroCfgDlg.obj : error LNK2005: "void __cdecl set_key(struct HWND__ *,int &)" (?set_key@@YAXPAUHWND__@@AAH@Z) already defined in AntiRecoilCfgDlg.obj
1>E:\Programming\Visual Studio 2008\Quick Keys\Debug\Quick Keys.exe : fatal error LNK1169: one or more multiply defined symbols found
If you guies need the actual source code I'd be happy to post that as well.
Thanks in advance,
Guitarist809