From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Lance Taylor To: law@cygnus.com Cc: hjl@lucon.org, svivanov@pdmi.ras.ru, egcs@cygnus.com Subject: Re: Why link C with crtstuff? [patch] Date: Sun, 26 Apr 1998 12:08:00 -0000 Message-id: <199804261903.PAA04748@subrogation.cygnus.com> References: <19451.893610286@hurl.cygnus.com> X-SW-Source: 1998-04/msg01044.html Date: Sun, 26 Apr 1998 11:04:46 -0600 From: Jeffrey A Law 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; }