[Lldb-commits] [lldb] [lldb] [Windows] Add a missing include. NFC. (PR #223727)

Martin Storsjö via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 15 07:49:58 PDT 2026


https://github.com/mstorsjo created https://github.com/llvm/llvm-project/pull/223727

_open_osfhandle is defined in io.h, which wasn't explicitly included before.

This built fine in practice with both WinSDK and recent mingw-w64 headers, but failed with older versions of mingw-w64 (older than August 2026).

Also change an accidental #if into #ifdef.

This fixes regressions from 1ca6698be7708121f987d0acf896c7dc4cf63a51 and ba1687b72476eb368641b9a9f565a38cf41b7393.

>From 435579fd2991c05efa341a263f49410e74b5f069 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin at martin.st>
Date: Tue, 15 Sep 2026 17:42:01 +0300
Subject: [PATCH] [lldb] [Windows] Add a missing include. NFC.

_open_osfhandle is defined in io.h, which wasn't explicitly included
before.

This built fine in practice with both WinSDK and recent mingw-w64
headers, but failed with older versions of mingw-w64 (older than
August 2026).

Also change an accidental #if into #ifdef.

This fixes regressions from 1ca6698be7708121f987d0acf896c7dc4cf63a51
and ba1687b72476eb368641b9a9f565a38cf41b7393.
---
 lldb/source/API/SBFile.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lldb/source/API/SBFile.cpp b/lldb/source/API/SBFile.cpp
index ab8e6e152d39e8..1ec3e1e6df451c 100644
--- a/lldb/source/API/SBFile.cpp
+++ b/lldb/source/API/SBFile.cpp
@@ -11,6 +11,10 @@
 #include "lldb/Host/File.h"
 #include "lldb/Utility/Instrumentation.h"
 
+#ifdef _WIN32
+#include <io.h>
+#endif
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -70,7 +74,7 @@ SBFile::SBFile(int fd, const char *mode, bool transfer_ownership) {
 }
 
 int SBFile::OpenFdFromHandle(intptr_t handle, int flags) {
-#if _WIN32
+#ifdef _WIN32
   return _open_osfhandle(handle, flags);
 #else
   (void)handle;



More information about the lldb-commits mailing list