This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: ATTRIBUTE_WEAK
- To: "H.J. Lu" <hjl at lucon dot org>
- Subject: Re: ATTRIBUTE_WEAK
- From: Bill Currie <bcurrie at tssc dot co dot nz>
- Date: Thu, 25 Feb 1999 09:53:59 +1300
- CC: law at cygnus dot com, egcs at egcs dot cygnus dot com
- Organization: NZ Telecommincations Systems Support Center
- References: <m10Fie3-000390C@ocean.lucon.org>
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