在 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 ` 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