Re: [Mingw-w64-public] mingw-w64 and __attribute__((format(printf))) issue

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

 



在 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: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux