[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [patch] Use inttypes macros for size_t format string

On 22.01.20 12:25, Tilo Eckert wrote:

> Am 22.01.2020 um 08:49 schrieb Andreas Schneider:
>> On Thursday, 16 January 2020 12:55:07 CET g4-lisz@xxxxxxxxxxxx wrote:
>>>>> According to that you need to compile with:
>>>> Alternative seems to be:
>>>> -Dsnprintf=__mingw_snprintf -Dvsnprintf=__mingw_vsnprintf ...
>>> Yes i was a bit overhasty with this patch...
>>> I also found that _POSIX_SOURCE does the trick. This would be a bit more
>>> generic.
>>> But I realized that the binaries get bigger like that, probably because
>>> they link in more of their own implementations. Not sure, if this is a
>>> good thing...
>>> -Dsnprintf=__mingw_snprintf -Dvsnprintf=__mingw_vsnprintf looks like a
>>> good compromise to me. I will also test this.
>> Which route should we go? Just set _POSIX_SOURCE?
> None of them. If you want libssh to work on Windows when built without
> MinGW, %z must not be used at all. The Windows implementation of printf
> does not support it. You have to use typecasts to print size_t in a
> portable way.
> Defining __USE_MINGW_ANSI_STDIO directly has been deprecated and emits a
> warning in newer MinGW versions:
> https://osdn.net/projects/mingw/scm/git/mingw-org-wsl/commits/36fae3c324a1997356db40caa83d0fac512b9407
> (deprecated) implicitly enables __USE_MINGW_ANSI_STDIO. MinGW replaces
> the printf and scanf function families with C99 compliant versions if
> any of the defines is set, leading to slightly larger binaries. However,
> that would only fix it if MinGW is used...
I was initially talking about compiling with MinGW...

For Windows I can find documentation of "z" as supported spezifier:

But not sure since when this is supported.

But anway: What is the advantage of using typecasts instead of a format
spezifier macro (see my patch)? You still have to use OS specific type
casts. Or I'm understanding this wrong?

I really had difficulties to find out which are the official sources of
MinGW. So it's not here any longer?


Archive administrator: postmaster@lists.cynapses.org