bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* [PATCH] stdint: port intptr_t to more-recent MinGW
@ 2020-08-12 18:30 Paul Eggert
  2020-08-12 18:49 ` Paul Eggert
  2020-08-12 19:26 ` Bruno Haible
  0 siblings, 2 replies; 3+ messages in thread
From: Paul Eggert @ 2020-08-12 18:30 UTC (permalink / raw
  To: bug-gnulib; +Cc: Paul Eggert

Problem reported by Eli Zaretskii in <https://bugs.gnu.org/36597#106>.
* lib/stdint.in.h (intptr_t, uintptr_t): Do not define on MinGW,
even if _INTPTR_T_DEFINED and _UINTPTR_T_DEFINED are not defined.
Apparently those two macros were removed in mingwrt-3.22
dated 2016-07-14.
---
 ChangeLog       | 9 +++++++++
 lib/stdint.in.h | 5 ++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 986b882a6..20319c82a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2020-08-12  Paul Eggert  <eggert@cs.ucla.edu>
+
+	stdint: port intptr_t to more-recent MinGW
+	Problem reported by Eli Zaretskii in <https://bugs.gnu.org/36597#106>.
+	* lib/stdint.in.h (intptr_t, uintptr_t): Do not define on MinGW,
+	even if _INTPTR_T_DEFINED and _UINTPTR_T_DEFINED are not defined.
+	Apparently those two macros were removed in mingwrt-3.22
+	dated 2016-07-14.
+
 2020-08-12  Bruno Haible  <bruno@clisp.org>
 
 	thread-optim: Export function-like macros only.
diff --git a/lib/stdint.in.h b/lib/stdint.in.h
index 324f5e8b2..cbfb53b43 100644
--- a/lib/stdint.in.h
+++ b/lib/stdint.in.h
@@ -302,12 +302,11 @@ typedef gl_uint_fast32_t gl_uint_fast16_t;
 /* kLIBC's <stdint.h> defines _INTPTR_T_DECLARED and needs its own
    definitions of intptr_t and uintptr_t (which use int and unsigned)
    to avoid clashes with declarations of system functions like sbrk.
-   Similarly, mingw 5.22 <crtdefs.h> defines _INTPTR_T_DEFINED and
-   _UINTPTR_T_DEFINED and needs its own definitions of intptr_t and
+   Similarly, MinGW WSL-5.4.1 <stdint.h> needs its own intptr_t and
    uintptr_t to avoid conflicting declarations of system functions like
    _findclose in <io.h>.  */
 # if !((defined __KLIBC__ && defined _INTPTR_T_DECLARED) \
-       || (defined __MINGW32__ && defined _INTPTR_T_DEFINED && defined _UINTPTR_T_DEFINED))
+       || defined __MINGW32__)
 #  undef intptr_t
 #  undef uintptr_t
 #  ifdef _WIN64
-- 
2.17.1



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

* Re: [PATCH] stdint: port intptr_t to more-recent MinGW
  2020-08-12 18:30 [PATCH] stdint: port intptr_t to more-recent MinGW Paul Eggert
@ 2020-08-12 18:49 ` Paul Eggert
  2020-08-12 19:26 ` Bruno Haible
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Eggert @ 2020-08-12 18:49 UTC (permalink / raw
  To: Gnulib bugs

Following up on this patch, here's a brief explanation. In 
<https://bugs.gnu.org/36597> we were battling with a problem building Emacs 
under 32-bit MinGW. The problem was that Gnulib stdint.in.h did this:

   # if !((defined __KLIBC__ && defined _INTPTR_T_DECLARED) \
	 || (defined __MINGW32__ && defined _INTPTR_T_DEFINED && defined 
_UINTPTR_T_DEFINED))
   #  undef intptr_t
   #  undef uintptr_t
   #  ifdef _WIN64
   typedef long long int gl_intptr_t;
   typedef unsigned long long int gl_uintptr_t;
   #  else
   typedef long int gl_intptr_t;
   typedef unsigned long int gl_uintptr_t;
   #  endif
   #  define intptr_t gl_intptr_t
   #  define uintptr_t gl_uintptr_t
   # endif

which makes intptr_t 'long', whereas Gnulib inttypes.in.h did this:

   #if !defined PRIdPTR
   # ifdef INTPTR_MAX
   #  define PRIdPTR @PRIPTR_PREFIX@ "d"
   # endif
   #endif

and since MinGW's PRIdPTR is already "d" this leaves it "d". Later when Emacs 
code did something like this:

   intptr_t ip; ...
   printf ("%PRIdPTR, ip);

GCC complained:

   warning: format '%d' expects argument of type 'int', but argument 2 has type 
'gl_intptr_t' {aka 'long int'} [-Wformat=]

The code ran OK since 'int' and 'long' are the same, but we wanted to squelch 
the warning.


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

* Re: [PATCH] stdint: port intptr_t to more-recent MinGW
  2020-08-12 18:30 [PATCH] stdint: port intptr_t to more-recent MinGW Paul Eggert
  2020-08-12 18:49 ` Paul Eggert
@ 2020-08-12 19:26 ` Bruno Haible
  1 sibling, 0 replies; 3+ messages in thread
From: Bruno Haible @ 2020-08-12 19:26 UTC (permalink / raw
  To: bug-gnulib; +Cc: Paul Eggert

> * lib/stdint.in.h (intptr_t, uintptr_t): Do not define on MinGW,

I can confirm that this patch works fine on my copy of mingw(-w64) from 2017.

Bruno



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

end of thread, other threads:[~2020-08-12 19:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-12 18:30 [PATCH] stdint: port intptr_t to more-recent MinGW Paul Eggert
2020-08-12 18:49 ` Paul Eggert
2020-08-12 19:26 ` 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).