Re: [hatari-devel] printf for 64 bit value and %PRId64/ %I64d |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
- To: hatari-devel@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [hatari-devel] printf for 64 bit value and %PRId64/ %I64d
- From: Uwe Seimet <Uwe.Seimet@xxxxxxxxx>
- Date: Sat, 17 Jul 2021 21:08:31 +0200
- Authentication-results: strato.com; dkim=none
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1626548911; s=strato-dkim-0002; d=seimet.de; h=In-Reply-To:References:Message-ID:Subject:To:From:Date:Cc:Date:From: Subject:Sender; bh=zZY6IcANCtZkfgpD0jdrsk5QLeFX92VVVfu4Iw7sD+w=; b=R460pRDaI+7z8dnVNxU75lgx963ds9XeCnJJgq3FwcOyRIfQBlDl6VDmilt+Sn3bwS NjzBWookFhr7IRfZOJu7FujLplrJKF0pD/7JURl2YxzLWgZdjCg/ddOr+Ie+h+1lxZf9 kByGMwYrklAV2+fiqnzaERvGlj54yPS0PhpJGEwBR2aM4+dk6H5myeOWw/aC+HrEN/o6 YboOi1dCOxWNNEbnavR/9UAxblvU93Cr+b5Y3uSACsKWRXreTQgNZOG9OlhAVsMxsiEY nRTAekwATY8Glkt9R0Xcn5zxSC9gMyR4NWffhXodxHRHi4lnXGPGvVinAjDnKb/9aggY lslQ==
Hi,
I guess adding some C++ code to Hatari is not an option, is it? In this
case one could use C++ streams for formatting, which eliminates string I/O
formatting issues.
Take care
Uwe
> Am Sat, 17 Jul 2021 17:25:33 +0200
> schrieb Nicolas Pomarède <npomarede@xxxxxxxxxxxx>:
>
> > Hi
> >
> > it seems that with recent version of mingw/gcc that I'm using there's
> > now an error when using the portable %PRId64 macro to print 64 bit
> > integer and crosscompiling under linux to do a Windows build :
> >
> >
> > /home/npomarede/src/win/src/gemdos.c: In function
> > 'restore_file_handle_info':
> > /home/npomarede/src/win/src/gemdos.c:891:24: warning: unknown
> > conversion type character 'l' in format [-Wformat=]
> > 891 | Log_Printf(LOG_WARN, "GEMDOS '%s' handle %d cannot be
> > restored, seek to saved offset %"PRId64" failed for: %s\n",
> > |
> > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > In file included from /home/npomarede/src/win/src/gemdos.c:42:
> > /usr/x86_64-w64-mingw32/sys-root/mingw/include/inttypes.h:33:18:
> > note: format string is defined here
> > 33 | #define PRId64 "lld"
> > | ^
> >
> > One possible fix for this is to do :
> >
> > #define PRId64 "I64d"
> >
> > only when compiling for windows (as %I64d seems to be more supported
> > under Windows)
> >
> > Any other idea how to fix this in the most clean/secure way ?
>
> IIRC I once hit this problem already, too, when the Fedora container in
> the gitlab-CI got upgraded to F34 (see commit 89ce85e772bc5ccd1) ... I
> had a look at it, but did not come to a clean solution. I think it has
> something to do with MinGW supporting both, the printf-style functions
> from the MS runtime, and the C99-style macros, at the same time.
>
> I did not find a clean solution back then and simply downgraded the
> container to F33 to "fix" it. But I think you could try playing with
> __attribut__((format(gnu_printf, 2, 3))) instead of the normal "printf"
> attribute - but beware, it might not be supported by Clang. Or maybe
> check the __USE_MINGW_ANSI_STDIO define ... but I think it also did not
> work for me back then.
> Alternatively cast the value to (long) and use "%l" instead (if
> it's unlikely that the value is bigger than 32-bit)?
>
> Thomas
>
>