[cfe-dev] Weak aliases on OSX

Douglas Gregor dgregor at apple.com
Mon Sep 26 07:29:32 PDT 2011


On Sep 25, 2011, at 3:15 AM, Martin Whitaker wrote:

> Hi,
> 
> On another open source project I work on, one of our users is trying to build 
> the code for OSX 10.7 using clang. This is failing on the following piece of code:
> 
> PLI_INT32 tf_getlongtime(PLI_INT32 *high)
> {
>       return tf_igetlongtime(high, 0);
> }
> 
> PLI_INT32 tf_getlongsimtime(PLI_INT32 *high) \
>       __attribute__ ((weak, alias ("tf_getlongtime")));
> 
> clang gives the following error:
> 
> getsimtime.c:88:29: error: only weak aliases are supported on darwin
> __attribute__ ((weak, alias ("tf_getlongtime")));
> ^
> 
> Looking at the clang source code, it appears to reject any form of alias when 
> targeting darwin. So is the error message wrong, or is there an alternative 
> way to create a weak alias that works for darwin?


I think the correct alternative is the weakref attribute documented here:

	http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html

	- Doug



More information about the cfe-dev mailing list