Skip to content

Fix native extension build on mswin - #224

Open
hsbt wants to merge 1 commit into
socketry:mainfrom
hsbt:mswin-build
Open

Fix native extension build on mswin#224
hsbt wants to merge 1 commit into
socketry:mainfrom
hsbt:mswin-build

Conversation

@hsbt

@hsbt hsbt commented Sep 11, 2026

Copy link
Copy Markdown

Installing io-event on mswin (x64-mswin64_140) fails because ext/io/event/interrupt.c includes unistd.h, which MSVC does not ship. Guarding that include is not enough. The existing rb_w32_pipe fallback is skipped because ruby's mswin config.h defines HAVE_PIPE, while the pipe macro in ruby/win32.h is only visible when building ruby itself. extconf.rb also never checked for ruby/win32.h, so that fallback was dead code.

I made extconf.rb detect unistd.h and ruby/win32.h, and changed the fallback to define pipe whenever the macro is missing. The extension now builds with MSVC 14.51, and IO::Event::Selector::Select works for a basic io_wait on a pipe. This is independent of the IOCP selector in #188, which leaves interrupt.c untouched.

Generated with Claude Code

There is no `unistd.h`, and the `pipe` emulation macro in `ruby/win32.h` is only visible while building ruby itself, while `HAVE_PIPE` is still defined in its config.h.
Guard the include and define `pipe` using `rb_w32_pipe` whenever the macro is missing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant