bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* inttypes: Fix PRI*PTR and SCN*PTR on 64-bit native Windows
@ 2020-07-21  7:56 Bruno Haible
  2020-08-23 22:52 ` Bruno Haible
  0 siblings, 1 reply; 2+ messages in thread
From: Bruno Haible @ 2020-07-21  7:56 UTC (permalink / raw)
  To: bug-gnulib

On 64-bit native Windows, PRIPTR_PREFIX comes out as "l", which produces
wrong output of intptr_t values through *printf. It should be "ll" instead.


2020-07-21  Bruno Haible  <bruno@clisp.org>

	inttypes: Fix PRI*PTR and SCN*PTR on 64-bit native Windows.
	* m4/inttypes.m4 (gl_INTTYPES_PRI_SCN): On 64-bit native Windows, make
	sure PRIPTR_PREFIX is defined to "ll", not "l".

diff --git a/m4/inttypes.m4 b/m4/inttypes.m4
index 224d0cd..f9f5f86 100644
--- a/m4/inttypes.m4
+++ b/m4/inttypes.m4
@@ -1,4 +1,4 @@
-# inttypes.m4 serial 29
+# inttypes.m4 serial 30
 dnl Copyright (C) 2006-2020 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -39,8 +39,17 @@ AC_DEFUN([gl_INTTYPES_PRI_SCN],
 
   PRIPTR_PREFIX=
   if test -n "$STDINT_H"; then
-    dnl Using the gnulib <stdint.h>. It always defines intptr_t to 'long'.
-    PRIPTR_PREFIX='"l"'
+    dnl Using the gnulib <stdint.h>. It defines intptr_t to 'long' or
+    dnl 'long long', depending on _WIN64.
+    AC_COMPILE_IFELSE(
+      [AC_LANG_PROGRAM([[
+         #ifdef _WIN64
+         LLP64
+         #endif
+         ]]),
+      ],
+      [PRIPTR_PREFIX='"l"'],
+      [PRIPTR_PREFIX='"ll"'])
   else
     dnl Using the system's <stdint.h>.
     for glpfx in '' l ll I64; do



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: inttypes: Fix PRI*PTR and SCN*PTR on 64-bit native Windows
  2020-07-21  7:56 inttypes: Fix PRI*PTR and SCN*PTR on 64-bit native Windows Bruno Haible
@ 2020-08-23 22:52 ` Bruno Haible
  0 siblings, 0 replies; 2+ messages in thread
From: Bruno Haible @ 2020-08-23 22:52 UTC (permalink / raw)
  To: bug-gnulib

> 2020-07-21  Bruno Haible  <bruno@clisp.org>
> 
> 	inttypes: Fix PRI*PTR and SCN*PTR on 64-bit native Windows.
> 	* m4/inttypes.m4 (gl_INTTYPES_PRI_SCN): On 64-bit native Windows, make
> 	sure PRIPTR_PREFIX is defined to "ll", not "l".

Oops, there was a typo in this patch, leading to PRIdPTR = "lld" instead of "ld"
on 32-bit native Windows.


2020-08-23  Bruno Haible  <bruno@clisp.org>

	inttypes: Fix {PRI,SCN}*PTR on 32-bit native Windows (regr. 2020-07-21).
	* m4/inttypes.m4 (gl_INTTYPES_PRI_SCN): Fix syntax error in test
	program.

diff --git a/m4/inttypes.m4 b/m4/inttypes.m4
index 28bac81..84b1654 100644
--- a/m4/inttypes.m4
+++ b/m4/inttypes.m4
@@ -1,4 +1,4 @@
-# inttypes.m4 serial 31
+# inttypes.m4 serial 32
 dnl Copyright (C) 2006-2020 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -44,7 +44,7 @@ AC_DEFUN([gl_INTTYPES_PRI_SCN],
          #ifdef _WIN64
          LLP64
          #endif
-         ]]),
+         ]])
       ],
       [PRIPTR_PREFIX='"l"'],
       [PRIPTR_PREFIX='"ll"'])



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-23 22:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-21  7:56 inttypes: Fix PRI*PTR and SCN*PTR on 64-bit native Windows Bruno Haible
2020-08-23 22:52 ` Bruno Haible

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).