Skip navigation.
 
mlRe: weak linking
FROM : Gerriet M. Denkmann
DATE : Sun Mar 30 15:48:57 2008

On 30 Mar 2008, at 01:47, <email_removed> wrote:
>
> I use in some Cocoa app a weak linked library.


[...]

> if (weak_function == NULL)
> {
>     NSLog(@"%s weak_function %p NULL", __FUNCTION__, weak_function );
> }
> else
> {
>     NSLog(@"%s weak_function %p non-NULL", __FUNCTION__, weak_function );
> }
>
> The result without library is:
> ... weak_function 0x0 non-NULL
>
> 10.4.11, powerpc-apple-darwin8-gcc-4.0.1.


Without this line:
extern void weak_function() __attribute__((weak_import));
the compiler notices that weak_function is non-NULL during 
compilation and optimizes under the assumption that it will remain 
non-NULL even at run time.

Kind regards,

Gerriet.

Related mailsAuthorDate
mlweak linking Gerriet M. Denkman… Mar 30, 01:32
mlRe: weak linking Gerriet M. Denkman… Mar 30, 15:48