Click here to Skip to main content
15,913,084 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Rich edit control problem Pin
Maximilien3-May-05 6:58
Maximilien3-May-05 6:58 
GeneralPopUp Menu Disabled in ActiveX Pin
javi_jmc3-May-05 4:18
javi_jmc3-May-05 4:18 
GeneralRe: PopUp Menu Disabled in ActiveX Pin
Wes Aday3-May-05 4:39
professionalWes Aday3-May-05 4:39 
GeneralRe: PopUp Menu Disabled in ActiveX Pin
javi_jmc3-May-05 4:58
javi_jmc3-May-05 4:58 
GeneralRe: PopUp Menu Disabled in ActiveX Pin
Wes Aday3-May-05 9:19
professionalWes Aday3-May-05 9:19 
GeneralRe: PopUp Menu Disabled in ActiveX Pin
javi_jmc3-May-05 12:26
javi_jmc3-May-05 12:26 
GeneralRe: PopUp Menu Disabled in ActiveX Pin
Anonymous3-May-05 13:43
Anonymous3-May-05 13:43 
GeneralLNK2005 Error (not CRT or MFC library) Pin
ricecake3-May-05 4:10
ricecake3-May-05 4:10 
OK, so I have a header file which I call NewTypes.h that has definitions for several structs. In particular, I have a struct PPLoutput, and I have overloaded the << operator so I can output it easily. The signature I am using for the operator is:

std::ostream& operator<<(std::ostream& s, const PPLoutput& p);

If I have the definition for this function in the header file, then I get the errors at the bottom (all files compile cleanly. I am having problems in the linking phase). Of course, I need to have NewTypes.h #included in multiple files. I have two multiple-include guards (#pragma and #ifndef). So, the file looks like:

#pragma once<br />
<br />
#ifndef NEWTYPES_H<br />
#define NEWTYPES_H<br />
<br />
/* Irrelevant stuff */<br />
<br />
struct PPLoutput<br />
{<br />
    /* ... */<br />
};<br />
<br />
std::ostream& operator<<(std::ostream& s, const PPLoutput& p)<br />
{<br />
    /* ... */<br />
};<br />
<br />
#endif


If I move the definition of operator<< to a different file (Combo.cpp), then it compiles and links fine. How do I get it to link while keeping it in NewTypes.h? I am using Visual Studio .NET 2003.


Errors below:
Combo.obj : error LNK2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __fastcall operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,struct PPLoutput const &)" (??6@YIAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABUPPLoutput@@@Z) already defined in 3PLComboDlg.obj
ComboDlg.obj : error LNK2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __fastcall operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,struct PPLoutput const &)" (??6@YIAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABUPPLoutput@@@Z) already defined in 3PLComboDlg.obj
LNP.obj : error LNK2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __fastcall operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,struct PPLoutput const &)" (??6@YIAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABUPPLoutput@@@Z) already defined in 3PLComboDlg.obj
LNPDlg.obj : error LNK2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __fastcall operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,struct PPLoutput const &)" (??6@YIAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABUPPLoutput@@@Z) already defined in 3PLComboDlg.obj
Release/3PLCombo.exe : fatal error LNK1169: one or more multiply defined symbols found

--
Marcus Kwok
GeneralRe: LNK2005 Error (not CRT or MFC library) Pin
eli150219793-May-05 4:16
eli150219793-May-05 4:16 
GeneralRe: LNK2005 Error (not CRT or MFC library) Pin
ricecake3-May-05 4:36
ricecake3-May-05 4:36 
GeneralRe: LNK2005 Error (not CRT or MFC library) Pin
Bob Stanneveld3-May-05 4:58
Bob Stanneveld3-May-05 4:58 
GeneralRe: LNK2005 Error (not CRT or MFC library) Pin
ricecake3-May-05 5:26
ricecake3-May-05 5:26 
GeneralRe: LNK2005 Error (not CRT or MFC library) Pin
QuiJohn3-May-05 6:27
QuiJohn3-May-05 6:27 
GeneralRe: LNK2005 Error (not CRT or MFC library) Pin
Bob Stanneveld3-May-05 21:52
Bob Stanneveld3-May-05 21:52 
GeneralMemory Allocation over 64k Pin
Cambalindo3-May-05 4:10
Cambalindo3-May-05 4:10 
GeneralRe: Memory Allocation over 64k Pin
Zdeslav Vojkovic3-May-05 5:38
Zdeslav Vojkovic3-May-05 5:38 
GeneralRe: Memory Allocation over 64k Pin
David Crow3-May-05 5:40
David Crow3-May-05 5:40 
GeneralRe: Memory Allocation over 64k Pin
QuiJohn3-May-05 9:29
QuiJohn3-May-05 9:29 
GeneralOffice Automation - Catching MS Word Keyboard events Pin
Noman Altaf3-May-05 4:03
Noman Altaf3-May-05 4:03 
GeneralXML Pin
viliam3-May-05 3:55
viliam3-May-05 3:55 
GeneralHiTooltip for CToolBar Pin
includeh103-May-05 3:48
includeh103-May-05 3:48 
GeneralCHM File Format Pin
RajaniBhandari3-May-05 2:48
RajaniBhandari3-May-05 2:48 
GeneralRe: CHM File Format Pin
ThatsAlok3-May-05 21:13
ThatsAlok3-May-05 21:13 
GeneralRe: CHM File Format Pin
Joel Lucsy4-May-05 13:41
Joel Lucsy4-May-05 13:41 
GeneralVirtual memory Allocation Pin
ckkmohan3-May-05 2:47
ckkmohan3-May-05 2:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.