[PATCH] D33082: Fix Libc++ build with MinGW64

Martell Malone via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 25 16:44:23 PDT 2017


martell added a comment.

> ! In https://reviews.llvm.org/D33082#764617, @EricWF wrote:
>  Defining `_GNU_SOURCE` during the library build isn't enough, it's also has to be defined when people are using the headers,
>  and in that case we must depend on the compiler to pre-define it. Is it important that MinGW not define `_GNU_SOURCE` by default?

I'm not sure why this isn't the default, it could be some backwards compatability with mingw.org.
I will ask kai the author and find out.

> Also do you know why `asprintf` is declared by mingw-w64 but `vasprintf` isn't? At minimum I think we still need to declare `vasprintf` in the
>  headers because we can't count on `_GNU_SOURCE` being defined before `<features.h>` is first included, but we should be able to omit
>  the definition.

I believe it is in stdio.h but behind the guard `__USE_MINGW_ANSI_STDIO`
You are currently picking up is msvc compatable asprintf and not gnu.
Defining this will give you the gnu versions of both and also the GNU printf format specifiers.

> Are you suggesting that libc++ should stop declaring/defining these functions, at least publically?

We could in the future run into real world problems with projects that work with libstdc++ fine but will have problems with libc++ if a project implements its own version but
I wouldn't be too concerned about this right now because when that becomes a problem it will prompt people to get these into mingw-w64 upstream.


https://reviews.llvm.org/D33082





More information about the cfe-commits mailing list