[PATCH 2/3] Use the alias attribute with GNU compiler only

Guillem Jover guillem at hadrons.org
Wed Aug 28 10:30:20 UTC 2019


Hi!

It seems I completely forgot about the weak alias problem from your
previous patchset, sorry about that!

On Thu, 2019-08-22 at 16:55:43 +0200, Michael Haubenwallner wrote:
> +#ifdef __GNUC__

At least clang does also support this too. But…

> +#  define __strong_alias(newsym, sym, argsdecl, argspass) \
>  	__typeof__ (sym) newsym __attribute__ ((alias (#sym)));
>  
> +#else /* !__GNUC__ */
> +
> +/*
> + * There is the undocumented MSVC linker flag "/alternatename" for some
> + * kind of weak aliasing, but that works for 32bit (x86) MSVC only.
> + * So for compilers other than GCC we just provide real functions.
> + */
> +#  define __strong_alias(newsym, sym, argsdecl, argspass) \
> +    void newsym argsdecl { sym argspass; }

… in any case, I've now pushed most of the patches (thanks!), and I've
been checking around and I might have found a way to use a cleaner
macro with:

  <https://docs.microsoft.com/en-us/cpp/preprocessor/comment-c-cpp?view=vs-2019>
  <https://docs.microsoft.com/en-us/cpp/build/reference/linker-options?view=vs-2019>
  <https://docs.microsoft.com/en-us/cpp/build/reference/export-exports-a-function?view=vs-2019>

And even though from the following:

  <https://docs.microsoft.com/en-us/cpp/build/reference/decorated-names?view=vs-2019>

it might seem like only decorated names are to be used this way, from
this one:

  <https://docs.microsoft.com/en-us/cpp/build/reference/exports?view=vs-2019>

I'd expect any alias is possible. So, could you give the attached patch
a go?

Thanks,
Guillem
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libmd-msc-alias.patch
Type: text/x-diff
Size: 684 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/libbsd/attachments/20190828/79609328/attachment.patch>


More information about the libbsd mailing list