public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Liu Hao <lh_mouse@126.com>
To: mingw-w64-public@lists.sourceforge.net,
	"Martin Storsjö" <martin@martin.st>
Cc: "gcc-help@gcc.gnu.org" <gcc-help@gcc.gnu.org>
Subject: Re: [Mingw-w64-public] mingw-w64 and __attribute__((format(printf))) issue
Date: Thu, 7 May 2020 12:09:22 +0800	[thread overview]
Message-ID: <9ed00d40-d2e0-5d39-5627-5c2ea9d098b2@126.com> (raw)
In-Reply-To: <alpine.DEB.2.20.2005061256580.23006@cone.martin.st>


[-- Attachment #1.1: Type: text/plain, Size: 1298 bytes --]

在 2020/5/6 18:48, Martin Storsjö 写道:
> 
> So something like this should work:
> 
> #ifdef __MINGW32__
> #define PRINTF_FORMAT __MINGW_PRINTF_FORMAT
> #else
> #define PRINTF_FORMAT printf
> #endif
> 
> __attribute__((format(PRINTF_FORMAT)))
> 
> Not very pretty, but should work without hardcoding any assumptions
> about which format actually is used.
> 

This requires `#include <stdio.h>` first.

Also I don't think it is correct to check for `__MINGW32__` for this
purpose, as the original MinGW.org header doesn't seem to provide
`__MINGW_PRINTF_FORMAT` [1].

However a direct check for `__MINGW_PRINTF_FORMAT` should suffice [2].
It is building well now, albeit still with some minor warnings:

```
../../gcc-git/lto-plugin/lto-plugin.c:927:29: note: format string is
defined here
  927 |     sscanf (s, ".%" PRI_LL "x", &obj->out->id);
      |                  ~~~~~~~~~~~^
      |                             |
      |                             unsigned int *
      |                  %" PRI_LL "llx

```


[1]
https://osdn.net/projects/mingw/scm/git/mingw-org-wsl/blobs/5.3-trunk/mingwrt/include/stdio.h
[2]
https://github.com/msys2/MINGW-packages/pull/6453/files#diff-49b46b088a6393d449afcdbfbe4e710e



-- 
Best regards,
LH_Mouse


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2020-05-07  4:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-06  5:36 Liu Hao
2020-05-06 10:48 ` [Mingw-w64-public] " Martin Storsjö
2020-05-06 12:45   ` Liu Hao
2020-05-07  4:09   ` Liu Hao [this message]
2020-05-10  4:27 ` JonY
2020-05-10  9:03   ` Liu Hao
2020-05-12 11:14     ` JonY
2020-05-12 12:02       ` Jakub Jelinek
2020-05-12 13:15         ` Liu Hao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9ed00d40-d2e0-5d39-5627-5c2ea9d098b2@126.com \
    --to=lh_mouse@126.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=martin@martin.st \
    --cc=mingw-w64-public@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).