<div dir="ltr">Hi,<br>Yes, what @zturner proposes works. @<span style="font-size:12.8px">kubabrecka </span>Would that make your editor work fine?<br>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.<br>But just let me know what you prefer and I will do that.<br>Thanks,<br>Marcos</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 18, 2017 at 4:43 PM, Zachary Turner via Phabricator <span dir="ltr"><<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">zturner added a comment.<br>
<span class=""><br>
In <a href="https://reviews.llvm.org/D28596#649978" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D28596#649978</a>, @mpividori wrote:<br>
<br>
> > 2. Having a macro only around the function name, i.e.: `WEAK_ATTRIBUTE void WEAK_NAME(OnPrint)(const char *str) { code }`.<br>
><br>
> 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`.<br>
>  I mean, for non-windows `OnPrint` definition will be:<br>
><br>
>   void OnPrint(const char *str) {<br>
>     // Default implementation<br>
>   }<br>
><br>
><br>
> And for Windows, it will be:<br>
><br>
>   void OnPrint__def(const char *str) {<br>
>     // Default implementation<br>
>   }<br>
>   void OnPrint(const char *str);<br>
>   WIN_WEAK_ALIAS(OnPrint, OnPrint__def)<br>
><br>
><br>
> Thanks.<br>
<br>
<br>
</span>What if instead of getting it all into one line, we settle for this:<br>
<br>
  void WEAK_FN_DEF(OnPrint)(const char *str) {<br>
  }<br>
  WEAK_FN_ALIAS(OnPrint)<br>
<br>
The macro `WEAK_FN_ALIAS` could look like this:<br>
<br>
  #define WEAK_FN_ALIAS(Fn) \<br>
    decltype(Fn##__def) Fn; \<br>
    WIN_WEAK_ALIAS(Fn, Fn##__def)<br>
<br>
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`.<br>
<br>
<br>
<a href="https://reviews.llvm.org/D28596" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D28596</a><br>
<br>
<br>
<br>
</blockquote></div><br></div>