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]
Other format: [Raw text]

Re: PR7455: What is expected behavior for #pragma weak.


Steven Bosscher <s.bosscher@student.tudelft.nl> writes:

> #pragma weak bar = foo

Hmmm.  The SUN documentation here:
    http://docs.sun.com/db/doc/805-4955/6j4mg806k?a=view
says that the function must be declared before it is used in #pragma
weak.  Since #pragma weak exists for compatibility purposes--the gcc
way to handle it is attributes--it is probably fine that gcc requires
a declaration here, since that is compatible.

> extern int bar (void) __attribute__ ((weak));

This is different, since it does not declare bar to be an alias.  In
this case there is no need to actually say anything about bar if it is
not declared and if nothing references it.

Note that

extern int bar (void) __attribute__ ((weak, alias ("foo")));

should emit bar as a weak alias for foo--and, in the current sources,
it does.

Ian


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