W dniu 30.10.2018 o 13:59, Jacek Caban pisze:
> On 10/28/2018 10:28 PM, Mateusz wrote:
>> W dniu 28.10.2018 o 16:07, Jacek Caban pisze:
>>>
>>> On 28/10/2018 09:39, Liu Hao wrote:
>>>> 在 2018/10/27 19:52, Jacek Caban 写道:
>>>>> I don't see what makes __USE_MINGW_ANSI_STDIO a correct solution.
>>>>> Firefox builds use ucrt, which is sufficient for handling stdio (and
>>>>> official winapi+clang-cl builds use that anyway).
>>>>>
>>>> Oh I didn't know that had migrated to UCRT.
>>>>
>>>>> I took a look at this and I think we want a more radical solution. Right
>>>>> now we have _mingw_print_push.h/_mingw_print_pop.h hack that has no
>>>>> clean purpose to me. I did some git history checking and when it was
>>>>> introduced, it was important for __USE_MINGW_ANSI_STDIO because that was
>>>>> where printf/scanf functions were #defined. It was later removed and the
>>>>> only thing that's left there is a bunch of PRI* macros. Instead of
>>>>> defining and redefining them, we may just as well define them correctly
>>>>> in the first place.
>>>>>
>>>>> That's what the attached patch does. It also uses the same for ucrt and
>>>>> mingw stdio, leaving hackish values only for affected builds. This fixes
>>>>> Firefox issue and makes mingw stdio cleaner. It's not yet tested, I'm
>>>>> mostly sending it for comments now.
>>>>>
>>>> Yes those macros `scanf()` and `printf()` etc. were removed in
>>>> d4e56ae45d4f92598f7b393340efca93f3deff38 and now those functions are
>>>> implemented by conditional inline definitions. If no other inline
>>>> functions [1] in our headers rely on the old format specifiers, the
>>>> header <_mingw_print_push.h> is consequenctly unneeded thereafter.
>>>>
>>>> The circumstances of <_mingw_print_pop.h> are a bit more complex. It has
>>>> to restore `PRId64` etc. to the correct strings that correspond to what
>>>> `printf()` etc., after the inclusion of <inttypes.h>, will eventually
>>>> call. Thus at the moment <_mingw_print_pop.h> actually checks for
>>>> inclusion of <stdio.h> or <wchar.h> (there was an old thread about this
>>>> [2]), otherwise the following code may not produce the expected result:
>>>>
>>>> ```c
>>>> #define __USE_MINGW_ANSI_STDIO  1
>>>> #include <inttypes.h>
>>>> #include <stdint.h>
>>>>
>>>> // `PRIx64` is defined as `I64x` here, which will co-operate with
>>>> // `printf()` from MSVCRT rather than the inline one in <stdio.h>.
>>> In my proposed patch, it will be properly defined to llx in inttypes.h 
>>> (note that the patch makes inttypes.h aware of __USE_MINGW_ANSI_STDIO). By 
>>> defining it to the right value in the first place, we don't need to 
>>> redefine it later.
>> Now if it is defined __USE_MINGW_ANSI_STDIO and stdio.h is NOT included, it 
>> is I64x, with your patch it is changed to llx (that not works with 
>> msvcrt.dll without miracles from stdio.h).
> 
> Yes, but what's wrong with that? Doesn't that make more sense? What's
> the sense of depending on strio.h presence? I think that not depending
> on it will give more consistent results. And I suspect that current
> behaviour is a side effect of a hack and not really intended feature and
> as such I don't see a reason to preserve it.

Liu Hao example is the explanation.
printf("value = %" PRIx64 "\n", value);
should print 64-bit int 'value' regardless stdio.h is included or not.


>> Maybe it is simpler to leave *_pop.h and *_push.h like it is/was and change 
>> only condition from
>> #if defined(__USE_MINGW_ANSI_STDIO)
>> to
>> #if defined(__USE_MINGW_ANSI_STDIO) || __MSVCRT_VERSION__ >= 0x1400
>> for llx inttypes.
>>
>> I've attached patch proposition (and I removed the case when 
>> __USE_MINGW_ANSI_STDIO defined as 0 is like not defined -- it's too 
>> complicated).
> 
> Why do you want to remove support for __USE_MINGW_ANSI_STDIO? I think
> it's good to have a way for users to explicitly specify that they don't
> want mingw stdio.
> 
> Jacek

Now I see it, thanks!

I was wrongly thinking that if __USE_MINGW_ANSI_STDIO is not defined it is 
ms_printf, if it is defined it is mingw_printf.

Now I see that if __USE_MINGW_ANSI_STDIO is not defined it is fuzzy logic 
(_GNU_SOURCE and so on), if it is defined as 0 it should be ms_printf, if it is 
defined != 0 it should be mingw_printf. I will prepare new patch.

Regards,
Mateusz



_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to