[Mingw-users] Yet another compilation problem with building gcc 7.3.0

Back to archive index

Earnie earni****@users*****
Fri Jun 29 23:18:14 JST 2018


On 6/29/2018 6:10 AM, Keith Marshall wrote:
> On 29/06/18 07:26, Eli Zaretskii wrote:
>>> From: David Gressett <DGres****@amli-*****>
>>> Date: Thu, 28 Jun 2018 21:52:07 -0500
>>> ../../../src/gcc-7.3.0/gcc/ada/rtinit.c:195:44: error:
>>> '_O_U16TEXT' was not declared in this scope
>>>               __gnat_current_ccs_encoding = _O_U16TEXT;
>>>
>>> The other two undefined items were _O_WTEXT and _O_U8TEXT.
>>> For all three of these, the compiler suggested _O_TEXT as an
>>> alternative.
>>>
>>> rtinit.c includes <fcntl.h> which defines the three undefined items:
>>>
>>> #if (__MSVCRT_VERSION__ >= 0x0800)
>>> #define _O_WTEXT	0x10000
>>> #define _O_U16TEXT	0x20000
>>> #define _O_U8TEXT	0x40000
>>> #endif
>>>
>>> fcntl.h includes _mingw.h which includes mscrtver.h, which defines
>>> a default value for __MSVCRT_VERSION__
>>>
>>> The default value is 0x0600, so unless an overriding #define
>>> produces a larger value, these constants will be undefined.
>>
>> AFAIU, the above means that the Ada compiler has dropped support of
>> Windows versions before Vista, and the compiler you produce will be
>> unable to run on those older versions as it does on Windows 7 and
>> later.  Unless, that is, the source has some fallback for those older
>> versions (and _O_TEXT sounds like a good idea to me up front), but I
>> didn't look at the sources to see if they do have such a fallback, and
>> I don't really understand what that will do, since UTF-16 text will
>> not be supported that way.
>>
>> If you never intend to have your compiler to run on older systems,
>> just define __MSVCRT_VERSION__ to the higher number, I'd say.
>>
>> Keith will probably have a better insight.
> 
> Well, I really cannot condone any suggestion to arbitrarily define
> __MSVCRT_VERSION__; its purpose is to declare intent to link with one of
> Microsoft's non-free (not freely distributable) runtimes, such as
> MSVCR80.DLL or later, *instead* of the OS-provided MSVCRT.DLL.  As such,
> the *only* way it should *ever* be defined to a non-default value is via
> a custom GCC specs file, which *replaces* MSVCRT.DLL with the
> corresponding non-free alternative, in the list of default libraries
> passed to the linker.
> 
> As David notes, the default value for __MSVCRT_VERSION__ is specified as
> 0x0600; this, or any lesser value, is interpreted as a declaration of
> intent to maintain compatibility with default MSVCRT.DLL linking
> behaviour.  Comments within <msvcrtver.h>, (for which I assume David's
> reference to <mscrtver.h> is a typo), explain this.
> 
> That said, if Vista and later versions of MSVCRT.DLL now expose APIs to
> which these __MSVCRT_VERSION__ restricted constants relate, then the
> restriction in <fcntl.h> should reflect that, with a _WIN32_WINNT
> minimum version test to complement the __MSVCRT_VERSION__ restriction.
> 
> Would anyone care to propose a test case for such version specific
> support?  I no longer use Windows for any daily purpose, but I do still
> have the ability to test compatibility for WinXP and Win7, running
> either as a virtual machine.  Would anyone else be able to assist with
> testing on other (esp. legacy) Windows versions?
> 

The 2nd example from
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setmode
should suffice for a test case.  However, I don't have any existence of
any version of Windows less than 10.

My assumption here is that since this affects the standard API set such
as _setmode then support for these exists in the delivered MSVCRT.DLL
for all newer OS versions.  Therefore the __MSVCRT_VERSION__ macro is
not the correct guard and _WIN32_WINNT macro should be used.  However,
that would mean as distributed, we would only support _WIN32_WINNT >
VISTA as the build would require it.

-- 
Earnie




More information about the MinGW-Users mailing list
Back to archive index