Fix warnings about formats in printf-like functions on MS-Windows

* src/lisp.h (pI) [__MINGW32__]: Provide definition that will
hopefully DTRT with both MinGW64 and mingw.org's MinGW.  See
http://lists.gnu.org/archive/html/emacs-devel/2017-09/msg00171.html
for the details.
* src/conf_post.h (PRINTF_ARCHETYPE) [MINGW_W64]: Separate
definition specific to MinGW64.
(PRINTF_ARCHETYPE) [__MINGW32__]: For mingw.org's MinGW, use
__mingw_printf__ in ANSI-compatible mode.
This commit is contained in:
Eli Zaretskii 2017-09-14 20:38:42 +03:00
parent 56ab0c4a4c
commit 2c29280e7a
2 changed files with 30 additions and 3 deletions

View file

@ -255,7 +255,27 @@ extern int emacs_setenv_TZ (char const *);
#if GNUC_PREREQ (4, 4, 0) && defined __GLIBC_MINOR__
# define PRINTF_ARCHETYPE __gnu_printf__
#elif GNUC_PREREQ (4, 4, 0) && defined __MINGW32__
# define PRINTF_ARCHETYPE __ms_printf__
# ifdef MINGW_W64
/* When __USE_MINGW_ANSI_STDIO is non-zero (as set by config.h),
MinGW64 replaces printf* with its own versions that are
__gnu_printf__ compatible, and emits warnings for MS native %I64d
format spec. */
# if __USE_MINGW_ANSI_STDIO
# define PRINTF_ARCHETYPE __gnu_printf__
# else
# define PRINTF_ARCHETYPE __ms_printf__
# endif
# else /* mingw.org's MinGW */
/* Starting from runtime v5.0.0, mingw.org's MinGW with GCC 6 and
later turns on __USE_MINGW_ANSI_STDIO by default, replaces printf*
with its own __mingw_printf__ version, which still recognizes
%I64d. */
# if GNUC_PREREQ (6, 0, 0) && __MINGW32_MAJOR_VERSION >= 5
# define PRINTF_ARCHETYPE __mingw_printf__
# else /* __MINGW32_MAJOR_VERSION < 5 */
# define PRINTF_ARCHETYPE __ms_printf__
# endif /* __MINGW32_MAJOR_VERSION < 5 */
# endif /* MinGW */
#else
# define PRINTF_ARCHETYPE __printf__
#endif

View file

@ -94,9 +94,16 @@ typedef long long int EMACS_INT;
typedef unsigned long long int EMACS_UINT;
enum { EMACS_INT_WIDTH = LLONG_WIDTH, EMACS_UINT_WIDTH = ULLONG_WIDTH };
# define EMACS_INT_MAX LLONG_MAX
# ifdef __MINGW32__
/* MinGW supports %lld only if __USE_MINGW_ANSI_STDIO is non-zero,
which is arranged by config.h, and (for mingw.org) if GCC is 6.0 or
later and the runtime version is 5.0.0 or later. Otherwise,
printf-like functions are declared with __ms_printf__ attribute,
which will cause a warning for %lld etc. */
# if defined __MINGW32__ \
&& (!defined __USE_MINGW_ANSI_STDIO \
|| !(GNUC_PREREQ (6, 0, 0) && __MINGW32_MAJOR_VERSION >= 5))
# define pI "I64"
# else
# else /* ! MinGW */
# define pI "ll"
# endif
# else