[PATCH] D28596: [compiler-rt] General definition for weak functions.

Marcos Pividori via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 18 17:28:11 PST 2017


Hi,
Yes, what @zturner proposes works. @kubabrecka Would that make your editor
work fine?
I would prefer to use only one macro as I defined it before, because if we
use 2 macros, we always need to remember to include both.
But just let me know what you prefer and I will do that.
Thanks,
Marcos

On Wed, Jan 18, 2017 at 4:43 PM, Zachary Turner via Phabricator <
reviews at reviews.llvm.org> wrote:

> zturner added a comment.
>
> In https://reviews.llvm.org/D28596#649978, @mpividori wrote:
>
> > > 2. Having a macro only around the function name, i.e.: `WEAK_ATTRIBUTE
> void WEAK_NAME(OnPrint)(const char *str) { code }`.
> >
> > I can't do that because not only I need to change the name, I also need
> to add a linker pragma `WIN_WEAK_ALIAS(OnPrint, OnPrint__def)` and declare
> `OnPrint`.
> >  I mean, for non-windows `OnPrint` definition will be:
> >
> >   void OnPrint(const char *str) {
> >     // Default implementation
> >   }
> >
> >
> > And for Windows, it will be:
> >
> >   void OnPrint__def(const char *str) {
> >     // Default implementation
> >   }
> >   void OnPrint(const char *str);
> >   WIN_WEAK_ALIAS(OnPrint, OnPrint__def)
> >
> >
> > Thanks.
>
>
> What if instead of getting it all into one line, we settle for this:
>
>   void WEAK_FN_DEF(OnPrint)(const char *str) {
>   }
>   WEAK_FN_ALIAS(OnPrint)
>
> The macro `WEAK_FN_ALIAS` could look like this:
>
>   #define WEAK_FN_ALIAS(Fn) \
>     decltype(Fn##__def) Fn; \
>     WIN_WEAK_ALIAS(Fn, Fn##__def)
>
> On non-Windows platforms, it would just do nothing.  Apparently the crazy
> decltype magic works and should give you a definition named `OnPrint__def`
> and a forward declaration named `OnPrint`.
>
>
> https://reviews.llvm.org/D28596
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170118/6f588a47/attachment.html>


More information about the llvm-commits mailing list