References to values and weak references.

Fergus Henderson fjh at
Wed Nov 8 14:23:34 EST 2000

On 08-Nov-2000, Simon Marlow <simonmar at> wrote:
> > (2) the ability for FFI to link in values as weak external 
> > references.  (In other words
> >     the reference doesn't have to be resolved and you can 
> > find out if it has been.)
> >     So assuming (1) has been implemented, I might want 
> > something additionally like
> >        foreign import weak "default_arguments" 
> > getDefaultArguments :: IO (Maybe Addr)
> > Now while I would LIKE these features, they aren't there, and 
> > it won't cause me great
> > distress to work around their absence.  But why not implement 
> > them anyway?
> Do you know how to use existing support for weak references in the
> linker/assembler?  I believe GNU as/ld has them, but I can't find any
> reference in the docs.


	extern int foo __attribute__((weak));
	int main() {
		printf("%p", &foo);

This is documented in the gcc info pages.

In GNU as:

	.weak foo

Fergus Henderson <fjh at>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <>  |     -- the last words of T. S. Garp.

More information about the FFI mailing list