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: ATTRIBUTE_WEAK


> AFAIK, weak applies only to definitions, not to external references.
> What do you mean with a weak external reference, after all?

HJ already provided an example:

#pragma weak foo
extern void foo ();

bar (){
  if (foo) foo ();
}

On i586-pc-linux-gnu, I get

bar:
        ...
	movl $foo,%eax
	testl %eax,%eax
	je .L3
	call foo
.L3:
        ...
	.weak	foo

I.e. a weak external does not need to be defined; if it is not
defined, it's address is 0. It's a cool feature, and I'd say not
supporting it with __attribute__ is a bug.

Regards,
Martin


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