[PATCH] Allow dllimport/dllexport on inline functions and get the linkage right

Reid Kleckner rnk at google.com
Thu May 15 13:56:16 PDT 2014


On Thu, May 15, 2014 at 1:38 PM, Yunzhong Gao <
Yunzhong_Gao at playstation.sony.com> wrote:

> > Reid pointed out that we would get the linkage wrong for exported
> functions in C99 mode, and that the reasonable thing to do would be to use
> MS semantics dllimport/export inline functions. I'll update the patch to do
> this.
>
> @rnk. If I recall correctly, Microsoft does not support C99 inline. What
> does MinGw(64) do in this case?
>

They don't.  They follow something similar to C++ inline semantics in C,
with the extra caveat that an 'extern' redeclaration of an inline function
will force it to be emitted.  Either way, with or without 'extern', any
code for the function is comdat deduplicated with other instances of the
same function.

MinGW64 GCC basically treats dllexport as something that implies an extern
storage class.  This produces a strong external definition of foo:
inline __attribute__((dllexport)) void foo() {}

Things are simple for dllimport, because C99 inline already uses
available_externally linkage.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140515/8cb8ea73/attachment.html>


More information about the cfe-commits mailing list