On Apr 7, 11:00 am, David Thompson <dave.thomps...@verizon.netwrote:
Quote:
On Mon, 24 Mar 2008 21:21:09 -0700 (PDT), Raman
>
<ramanchalo...@gmail.comwrote:
Quote:
I have two libs (libFirst.a and libSecond.a). Both libs contains a
common function func(). Now I want to link an application "app" with
these two libs as
>
Quote:
gcc -o app libFirst.a libSecond.a app.c.
>
Quote:
It gives( and it should ) multiple declaration error . Is there any
way to tell the linker which func() declaration it must select.
>
Small but important terminology point: multiple _definition_.
>
A _definition_ in C provides the actual entity (an object, commonly
called a variable, or a function), and having more than one for the
same external name is a problem. Although one that the C standard does
not require an implementation to detect; you are mildly lucky that
your implementation did.
>
A _declaration_ is _sometimes_ (also) a definition, but when it isn't,
it only describes something defined elsewhere. It is definitely OK to
have external declarations in different T.U.s for the same external
entity, and that's the only (direct) way you can share it; it is also
legal to have multiple (compatible) declarations for the same external
entity in one T.U, and sometimes convenient.
>
That said, others have addressed the substance of your question.
>
- formerly david.thompson1 || achar(64) || worldnet.att.net
Taken a note of my ignorance.
Thanks,
Raman Chalotra