This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Prevent multiple definition of MIN/MAX
- From: "Paul E. Murphy" <murphyp at linux dot vnet dot ibm dot com>
- To: Joseph Myers <joseph at codesourcery dot com>
- Cc: "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>, Tulio Magno Quites Machado Filho <tuliom at linux dot vnet dot ibm dot com>, Carlos Eduardo Seo <cseo at linux dot vnet dot ibm dot com>
- Date: Tue, 17 Nov 2015 12:27:39 -0600
- Subject: Re: [PATCH] Prevent multiple definition of MIN/MAX
- Authentication-results: sourceware.org; auth=none
- References: <564B61EA dot 7030200 at linux dot vnet dot ibm dot com> <alpine dot DEB dot 2 dot 10 dot 1511171723360 dot 27820 at digraph dot polyomino dot org dot uk>
On 11/17/2015 11:25 AM, Joseph Myers wrote:
> On Tue, 17 Nov 2015, Paul E. Murphy wrote:
>
>> Some recent changes caused a redefinition and error when these
>> are unconditionally defined. Such was caused by gmp-impl.h being
>> included prior.
>>
>> 2015-11-17 Paul E. Murphy <murphyp@linux.vnet.ibm.com>
>>
>> * misc/sys/param.h (MIN): Guard against an outside definition.
>> (MAX): Likewise.
>
> This is an installed header, and such guards against the user defining a
> macro aren't usual in installed headers; the expectation is that if you
> include a system header, you don't define any of its macros first. See
> the options I suggested in
> <https://sourceware.org/ml/libc-alpha/2015-11/msg00289.html>.
>
Point taken. Lets try the more conservative option B:
shuffling the includes. Second spin attached.
>From 7ca7f888f09b76b62e07d32a45383342b01352ab Mon Sep 17 00:00:00 2001
From: "Paul E. Murphy" <murphyp@linux.vnet.ibm.com>
Date: Tue, 17 Nov 2015 11:41:21 -0600
Subject: [PATCH] Shuffle includes in ldbl-128ibm/mpn2ldl.c
Kind of hokey, but errno.h drags in misc/sys/param.h which
defines MIN/MAX causing an error. Include system headers
first to grab MIN/MAX definition in param.h, and define
HAVE_ALLOCA to preserve existing behavior.
2015-11-17 Paul E. Murphy <murphyp@linux.vnet.ibm.com>
* sysdeps/ieee754/ldbl-128ibm/mpn2ldl.c: Include gmp headers
after system headers to prevent MIN/MAX redefinition. Define
HAVE_ALLOCA to preserve builtin alloca usage.
---
sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c b/sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c
index 90dae93..c7ebd7e 100644
--- a/sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c
@@ -15,13 +15,17 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include "gmp.h"
-#include "gmp-impl.h"
#include <ieee754.h>
#include <errno.h>
#include <float.h>
#include <math.h>
+/* Need to set this when including gmp headers after system headers. */
+#define HAVE_ALLOCA 1
+
+#include "gmp.h"
+#include "gmp-impl.h"
+
/* Convert a multi-precision integer of the needed number of bits (106
for long double) and an integral power of two to a `long double' in
IBM extended format. */
--
2.4.3