Click here to Skip to main content
15,887,746 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to get SQL stored procedure output / return code Pin
neilsolent20-Jan-07 21:59
neilsolent20-Jan-07 21:59 
QuestionHow to SetEvenRowStyle in truedbgrid control in run time? Pin
liur1720-Jan-07 19:38
liur1720-Jan-07 19:38 
QuestionCtrl+Double click message Pin
Max++20-Jan-07 14:39
Max++20-Jan-07 14:39 
AnswerRe: Ctrl+Double click message Pin
PJ Arends20-Jan-07 19:22
professionalPJ Arends20-Jan-07 19:22 
AnswerRe: Ctrl+Double click message Pin
prasad_som21-Jan-07 1:36
prasad_som21-Jan-07 1:36 
AnswerRe: Ctrl+Double click message Pin
prasad_som21-Jan-07 1:32
prasad_som21-Jan-07 1:32 
QuestionASF Writer Directshow Filter Pin
gigo2k620-Jan-07 12:29
gigo2k620-Jan-07 12:29 
QuestionLNK2005 and template class Pin
Nick Alexeev20-Jan-07 12:27
professionalNick Alexeev20-Jan-07 12:27 
Folks,

I've written a template tokenizer class. (BTW, code and the write-up about this class is posted here http://www.codeproject.com/useritems/TemplateTokenizer.asp[^].) All of the template class' code (declaration and implementation) resides in one *.h file. Everything compiles, links and runs just fine, when the template class header file is #included only in one *.cpp file. But when the header is included into 2 *.cpp files, I get the linker errors:

ParseCSV2.obj : error LNK2005: "protected: void __thiscall CStringTokenizer<class CStringArray>::Add(char const *)" (?Add@?$CStringTokenizer@VCStringArray@@@@IAEXPBD@Z) already defined in ParseCSV.obj
ParseCSV2.obj : error LNK2005: "protected: void __thiscall CStringTokenizer<class CStringList>::Add(char const *)" (?Add@?$CStringTokenizer@VCStringList@@@@IAEXPBD@Z) already defined in ParseCSV.obj
Debug/ParsingNMEA.exe : fatal error LNK1169: one or more multiply defined symbols found


The header file has both #ifndef and #pragma once

#ifndef STRINGTOKENIZER_H
#define STRINGTOKENIZER_H
#pragma once
[declaration+implementation] 
#endif // STRINGTOKENIZER_H


Template class headers contain the implementation. They are included into both descendents. Linker sees this as an error. From the linker's perspective, these errors make sense.

What can I do to fix this problem?

Thanks!
Nick

P.S. It seems like it could be a fairly common problem, but I couldn't find a solution on this forum or on the web.

P.P.S. I'm using VC++ 6
AnswerRe: LNK2005 and template class Pin
Michael Dunn20-Jan-07 15:20
sitebuilderMichael Dunn20-Jan-07 15:20 
GeneralRe: LNK2005 and template class Pin
Sceptic Mole21-Jan-07 0:03
Sceptic Mole21-Jan-07 0:03 
QuestionRe: LNK2005 and template class Pin
Nick Alexeev21-Jan-07 19:44
professionalNick Alexeev21-Jan-07 19:44 
AnswerRe: LNK2005 and template class Pin
Michael Dunn21-Jan-07 19:58
sitebuilderMichael Dunn21-Jan-07 19:58 
QuestionWhat 's function that use for check control handle Pin
Max++20-Jan-07 7:40
Max++20-Jan-07 7:40 
AnswerRe: What 's function that use for check control handle Pin
CPallini20-Jan-07 10:39
mveCPallini20-Jan-07 10:39 
AnswerRe: What 's function that use for check control handle Pin
Mark Salsbery20-Jan-07 10:39
Mark Salsbery20-Jan-07 10:39 
AnswerRe: What 's function that use for check control handle Pin
prasad_som21-Jan-07 17:07
prasad_som21-Jan-07 17:07 
QuestionWorking on a custom control derived from CTreeCtrl Pin
Chen Ganir20-Jan-07 5:25
Chen Ganir20-Jan-07 5:25 
QuestionI want to write caller Id Application Pin
javad_200520-Jan-07 5:08
javad_200520-Jan-07 5:08 
AnswerRe: I want to write caller Id Application Pin
Blake Miller24-Jan-07 7:35
Blake Miller24-Jan-07 7:35 
QuestionHook Print Dialog in Word Pin
pgibson00770020-Jan-07 4:57
pgibson00770020-Jan-07 4:57 
AnswerRe: Hook Print Dialog in Word Pin
Mark Salsbery20-Jan-07 5:59
Mark Salsbery20-Jan-07 5:59 
AnswerRe: Hook Print Dialog in Word Pin
Michael Dunn20-Jan-07 9:39
sitebuilderMichael Dunn20-Jan-07 9:39 
GeneralRe: Hook Print Dialog in Word Pin
pgibson00770020-Jan-07 9:44
pgibson00770020-Jan-07 9:44 
GeneralRe: Hook Print Dialog in Word Pin
nelsonlam9-Nov-09 15:05
nelsonlam9-Nov-09 15:05 
GeneralRe: Hook Print Dialog in Word Pin
pgibson0077009-Nov-09 21:46
pgibson0077009-Nov-09 21:46 

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.