Prevent multiple definition of MIN/MAX
Commit Message
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.
Comments
On Tue, 17 Nov 2015, Paul E. Murphy wrote:
> 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.
OK.
Joseph Myers <joseph@codesourcery.com> writes:
> On Tue, 17 Nov 2015, Paul E. Murphy wrote:
>
>> 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.
>
> OK.
Pushed as 79adcb58.
Thanks!
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(-)
@@ -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