This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: ATTRIBUTE_WEAK


H.J. Lu wrote:
> extern void foo () __attribute__ ((weak));
> 
> bar ()
> {
>   if (foo) foo ();
> }

Correct me if I'm wrong, but isn't __attribute__ ((weak)) for when you
*define* a function, rather than reference it?  For your example, my
understanding says that the following is something closer to what's
intended:

-----
void __attribute__((weak)) foo()
{
}

-----
extern void foo();

bar()
{
  if (foo) foo();
}
-----

NOTE: I do not truly understand weak symbols, but I'm pretty sure it's
the definition that gets weakend (so it can be overridden) rather than
the reference (if the reference, would that be so the definition is
optional???).

Bill
-- 
Leave others their otherness


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]