[PATCH] Helpers: move some date related function to qt-gui.cpp

Lubomir I. Ivanov neolit123 at gmail.com
Tue Oct 15 07:22:44 UTC 2013


On 15 October 2013 16:54, Jef Driesen <jefdriesen at telenet.be> wrote:
> On 2013-10-15 15:14, Lubomir I. Ivanov wrote:
>>
>> MinGW support for *printf and parameter positions (e.g. %1$d)
>> is horribly broken. Instead of implementing *proper* support
>> for this feature Microsoft decide to ignore the standard (again)
>> and they implement new functions with the '_p' suffix,
>> such as 'sprintf_p', which seem to be available from a 2003 runtime.
>> To top that 'sprintf_p' is not really a 'sprintf' but rather
>> a 'snprintf'.
>>
>> It seems that the MinGW people ignore the issue and do not provide
>> wrappers of any sort, or at least for the current recommended compiler
>> for Qt 4.8.5 on Windows - which is a 4.4.0. A note of warning;
>> inspecting how MinGW does certain things in headers such as stdio.h,
>> can ensue bad dreams or other negative effects on to the viewer.
>
>
> The mingw compiler links your code against the Microsoft C library (msvcrt).
> Thus if the msvcrt library is broken (e.g. no C99 support!), then there is
> not much mingw can do about that.
>

yep, i'm sadly aware of that, but this particular feature exists in
newer CRT for sure.

> However, I believe mingw does provide it's own replacement implementation
> for the printf functions. Those work very well for me, but I never tried to
> used positional parameters, so don't take my word on that.
>

no support for that in mingw AFAIK...
it is also missing in msvc 98 and probably more older compilers but
available in the form of *printf_p for msvc 2003.

https://www.gnu.org/software/gnulib/manual/html_node/snprintf.html
"This function does not support format directives that access
arguments in an arbitrary order, such as "%2$s", on some platforms:
NetBSD 3.0, mingw, BeOS."

> Maybe you end up calling the Microsoft functions for some reason?
>
> http://web.archive.org/web/20120504105123/http://sourceforge.net/project/shownotes.php?release_id=24832
>

those should be called with '__msvcrt_' or with a '_' prefix in the
case of 'snprintf'.

lubomir
--


More information about the subsurface mailing list