From: Hans-Bernhard Broeker Newsgroups: comp.os.msdos.djgpp Subject: Re: A beginner's problem...! Date: 12 Feb 2001 12:06:08 GMT Organization: Aachen University of Technology (RWTH) Lines: 29 Message-ID: <968jjg$oq6$1@nets3.rz.RWTH-Aachen.DE> References: <3A7F202C DOT 12549DCB AT tinyworld DOT co DOT uk> <3A83FE6B DOT 26CA4E5B AT email DOT com> NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de X-Trace: nets3.rz.RWTH-Aachen.DE 981979568 25414 137.226.32.75 (12 Feb 2001 12:06:08 GMT) X-Complaints-To: abuse AT rwth-aachen DOT de NNTP-Posting-Date: 12 Feb 2001 12:06:08 GMT Originator: broeker@ To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Yong-Kwang Goh wrote: > Well, the linker encounters 2 copies of the function definition of the > function "sqr". Yes, but the reason for that happening is not what you think it is. Please note that the line "long sqr(int x);" is *not* a definition of function "sqr". It's a declaration, instead, and the linker doesn't care about multiple declarations at all. In fact, it doesn't even *see* them. > So the linker is confused when the same function is defined twice. I would > suggest you edit your "calc.h" as follows: > ------------------------------- > #ifndef CALC_H <== Add this line > #define CALC_H <== Add this as well > /*calc.h*/ > long sqr(int x); > #endif <== And lastly, don't forget to add this too. > ------------------------------- These additional lines are useful, indeed, but *not* for solving multiple definition problems reported by the linker. They're against multiple definitions of types, which the compiler would complain about, not the linker. -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.