Re: Fix compilation using mingw.org's MinGW

Pedro Alves
2019-04-30T17:58:47Z

On 4/30/19 6:40 PM, Eli Zaretskii wrote:

>>> But no matter where it is set, it must be defined after _any_
>>> standard header is included, so in practice I think it's defined at
>>> the place where the patch tests for it.
>> I think you mean "before".
> No, I meant "after". The default value is set once you included at
> least on standard header. Hence you can at that place test for
> whether it is defined and what is its default value.

Sorry, but no, there's no need to wait until there's a default to
override it.

In fact, your patch is doing exactly that. common-defs.h is garanteed
to be included before any started header. That's exactly why I suggested
that spot.

That's because the default is only defined if not already defined:

/* Select Default WIN32_WINNT Value */
#if !defined(_WIN32_WINNT) && !defined(_CHICAGO_)
#define _WIN32_WINNT _WIN32_WINNT_WS03
#endif

This family of macros is usually defined on the command line / Makefile
on Windows-only projects, even:

$CC -D_WIN32_WINNT=xxx

That's what MSVC/Visual Studio does. Or at least, used to last I used it,
years ago.

I did not suggest doing that because it's not as convenient on portable
projects that don't just target Windows.

> Overriding that
> default is generally important only before including w32api headers,
> such as windows.h.

Agreed. But defining it really early just makes sure it's consistently
set.

Thanks,
Pedro Alves