[flang-commits] [flang] [flang] fix build on FreeBSD after 4762c6557d15 (PR #86204)

Brooks Davis via flang-commits flang-commits at lists.llvm.org
Thu Mar 21 14:49:58 PDT 2024


https://github.com/brooksdavis created https://github.com/llvm/llvm-project/pull/86204

The HUGE definition collides with the HUGE macro from math.h.  Unlike the fix in 3149c934cb26 (#84478) (largely reverted in f95710c76519), add another #undef HUGE since there is no practical way to make FreeBSD's headers not define HUGE and still define XSI interfaces such as isascii or strnlen.

Fixes #86038

>From a805d8e5130cb073a787058e918962557d9d879a Mon Sep 17 00:00:00 2001
From: Brooks Davis <brooks at one-eyed-alien.net>
Date: Thu, 21 Mar 2024 21:39:46 +0000
Subject: [PATCH] [flang] fix build on FreeBSD after 4762c6557d15

The HUGE definition collides with the HUGE macro from math.h.  Unlike
the fix in 3149c934cb26 (#84478) (largely reverted in f95710c76519), add
another #undef HUGE since there is no practical way to make FreeBSD's
headers not define HUGE and still define XSI interfaces such as isascii or
strnlen.

Fixes #86038
---
 flang/lib/Decimal/decimal-to-binary.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/flang/lib/Decimal/decimal-to-binary.cpp b/flang/lib/Decimal/decimal-to-binary.cpp
index c5cdb72e355f62..3d9e0673b93777 100644
--- a/flang/lib/Decimal/decimal-to-binary.cpp
+++ b/flang/lib/Decimal/decimal-to-binary.cpp
@@ -16,6 +16,10 @@
 #include <ctype.h>
 #include <utility>
 
+// Some environments, viz. glibc 2.17, allow the macro HUGE
+// to leak out of <math.h>.
+#undef HUGE
+
 namespace Fortran::decimal {
 
 template <int PREC, int LOG10RADIX>



More information about the flang-commits mailing list