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: Why link C with crtstuff? [patch]


   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;
}


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