[flang-commits] [flang] [flang] Guard stdfloat include with __has_include check (PR #228953)

via flang-commits flang-commits at lists.llvm.org
Sun Oct 4 16:31:05 PDT 2026


https://github.com/rdong8 created https://github.com/llvm/llvm-project/pull/228953

Trunk libc++ does not currently supply this header, causing a compilation error when compiling with C++23 and above

>From 84307db6e12807da0b32ea6651c0e4cc2962ef65 Mon Sep 17 00:00:00 2001
From: Richard Dong <rdong8 at protonmail.com>
Date: Sun, 4 Oct 2026 20:36:46 +0000
Subject: [PATCH] [flang] Guard stdfloat include with __has_include check

Check __has_include(<stdfloat>) before including <stdfloat> in cpp-type.h
to avoid build failure on standard library implementations where <stdfloat>
is not yet available.
---
 flang/include/flang/Runtime/cpp-type.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/flang/include/flang/Runtime/cpp-type.h b/flang/include/flang/Runtime/cpp-type.h
index cc31ce2876abc..b9e259574ed47 100644
--- a/flang/include/flang/Runtime/cpp-type.h
+++ b/flang/include/flang/Runtime/cpp-type.h
@@ -17,7 +17,7 @@
 #include "flang/Common/uint128.h"
 #include "flang/Runtime/complex.h"
 #include <cstdint>
-#if __cplusplus >= 202302
+#if __cplusplus >= 202302 && __has_include(<stdfloat>)
 #include <stdfloat>
 #endif
 #include <type_traits>



More information about the flang-commits mailing list