bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* Gnulib's alloca.h and MinGW
@ 2020-06-29 17:27 Eli Zaretskii
  2020-06-29 22:55 ` Bruno Haible
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2020-06-29 17:27 UTC (permalink / raw)
  To: bug-gnulib

A recent MinGW runtime changed its definition of alloca from  an
inline function to a macro.  As result, there's a warning when
compiling Gnulib's malloca.c:

       CC       malloca.o
     In file included from malloca.h:21,
		      from malloca.c:22:
     ./alloca.h:46: warning: "alloca" redefined
	46 | #  define alloca __builtin_alloca
	   |
     In file included from ./alloca.h:44,
		      from malloca.h:21,
		      from malloca.c:22:
     d:\usr\include\alloca.h:81: note: this is the location of the previous definition
	81 | #define alloca( __request )  __builtin_alloca( __request )
	   |

Proposed patch is below.  Thanks.


--- alloca.h~0	2020-06-29 18:22:39.421875000 +0300
+++ alloca.h	2020-06-29 19:21:42.468750000 +0300
@@ -36,10 +36,16 @@
  */
 
 #ifndef alloca
+/* Some version of mingw have an <alloca.h> that causes trouble when
+   included after 'alloca' gets defined as a macro.  As a workaround,
+   include this <alloca.h> first and define 'alloca' as a macro
+   afterwards if needed.  */
+# if (defined __GNUC__ && defined _WIN32 && ! defined __CYGWIN__) && 1
+#  include_next <alloca.h>
+# endif
+#endif
+#ifndef alloca
 # ifdef __GNUC__
-   /* Some version of mingw have an <alloca.h> that causes trouble when
-      included after 'alloca' gets defined as a macro.  As a workaround, include
-      this <alloca.h> first and define 'alloca' as a macro afterwards.  */
 #  if (defined _WIN32 && ! defined __CYGWIN__) && 1
 #   include_next <alloca.h>
 #  endif


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

* Re: Gnulib's alloca.h and MinGW
  2020-06-29 17:27 Gnulib's alloca.h and MinGW Eli Zaretskii
@ 2020-06-29 22:55 ` Bruno Haible
  2020-06-30  2:30   ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Bruno Haible @ 2020-06-29 22:55 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Eli Zaretskii

Hi Eli,

> A recent MinGW runtime changed its definition of alloca from  an
> inline function to a macro.  As result, there's a warning when
> compiling Gnulib's malloca.c:
> 
>        CC       malloca.o
>      In file included from malloca.h:21,
> 		      from malloca.c:22:
>      ./alloca.h:46: warning: "alloca" redefined
> 	46 | #  define alloca __builtin_alloca
> 	   |
>      In file included from ./alloca.h:44,
> 		      from malloca.h:21,
> 		      from malloca.c:22:
>      d:\usr\include\alloca.h:81: note: this is the location of the previous definition
> 	81 | #define alloca( __request )  __builtin_alloca( __request )
> 	   |
> 
> Proposed patch is below.  Thanks.

Thanks for the report.

I like your patch. It is better than the '#undef alloca' solution that I
had considered before.


2020-06-29  Bruno Haible  <bruno@clisp.org>

	alloca-opt: Fix warning on mingw.
	Reported and solution by Eli Zaretskii <eliz@gnu.org> in
	<https://lists.gnu.org/archive/html/bug-gnulib/2020-06/msg00069.html>.
	* lib/alloca.in.h: On mingw, include <alloca.h> and then test again
	whether alloca is defined.

diff --git a/lib/alloca.in.h b/lib/alloca.in.h
index 73516ca..beb022c 100644
--- a/lib/alloca.in.h
+++ b/lib/alloca.in.h
@@ -35,13 +35,16 @@
  */
 
 #ifndef alloca
+  /* Some version of mingw have an <alloca.h> that causes trouble when
+     included after 'alloca' gets defined as a macro.  As a workaround,
+     include this <alloca.h> first and define 'alloca' as a macro afterwards
+     if needed.  */
+# if defined __GNUC__ && (defined _WIN32 && ! defined __CYGWIN__) && @HAVE_ALLOCA_H@
+#  include_next <alloca.h>
+# endif
+#endif
+#ifndef alloca
 # ifdef __GNUC__
-   /* Some version of mingw have an <alloca.h> that causes trouble when
-      included after 'alloca' gets defined as a macro.  As a workaround, include
-      this <alloca.h> first and define 'alloca' as a macro afterwards.  */
-#  if (defined _WIN32 && ! defined __CYGWIN__) && @HAVE_ALLOCA_H@
-#   include_next <alloca.h>
-#  endif
 #  define alloca __builtin_alloca
 # elif defined _AIX
 #  define alloca __alloca



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

* Re: Gnulib's alloca.h and MinGW
  2020-06-29 22:55 ` Bruno Haible
@ 2020-06-30  2:30   ` Eli Zaretskii
  0 siblings, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2020-06-30  2:30 UTC (permalink / raw)
  To: Bruno Haible; +Cc: bug-gnulib

> From: Bruno Haible <bruno@clisp.org>
> Cc: Eli Zaretskii <eliz@gnu.org>
> Date: Tue, 30 Jun 2020 00:55:49 +0200
> 
> > Proposed patch is below.  Thanks.
> 
> Thanks for the report.
> 
> I like your patch. It is better than the '#undef alloca' solution that I
> had considered before.

Thanks.


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

end of thread, other threads:[~2020-06-30  2:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-29 17:27 Gnulib's alloca.h and MinGW Eli Zaretskii
2020-06-29 22:55 ` Bruno Haible
2020-06-30  2:30   ` Eli Zaretskii

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