This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Why link C with crtstuff? [patch]
- To: law at cygnus dot com
- Subject: Re: Why link C with crtstuff? [patch]
- From: Ian Lance Taylor <ian at cygnus dot com>
- Date: Sun, 26 Apr 1998 15:03:05 -0400
- CC: hjl at lucon dot org, svivanov at pdmi dot ras dot ru, egcs at cygnus dot com
Date: Sun, 26 Apr 1998 11:04:46 -0600
From: Jeffrey A Law <law@cygnus.com>
In message <m0yTKUE-000598C@ocean.lucon.org>you write:
> BTW, Jim, I cannot get__ attribute__((weak)) to work on extern.
I don't think it should work on a function declaration.
Seems to me you have to have it on the function defintion or
there's no way for it to actually mark the function in question
as weak.
There are two kinds of weak symbols: weak defined symbols, which
clearly must be associated with a function definition, and weak
undefined symbols, which clearly can not be associated with a function
definition.
I don't know how to make a weak undefined symbol, except by using
#pragma weak. Here is an example that will make a weak defined symbol
bar and a weak undefined symbol foo. The attribute on foo has no
effect. If you remove the pragma, foo will not be weak.
Ian
extern int foo (int) __attribute__((__weak__));
#pragma weak foo
int bar (int) __attribute__ ((__weak__));
int
bar (int i)
{
if (foo)
return foo (i);
return i;
}