From d60e0211bc6a360da15be72c48b8062081e785f2 Mon Sep 17 00:00:00 2001 From: bptato <60043228+bptato@users.noreply.github.com> Date: Thu, 11 Sep 2025 23:45:47 +0200 Subject: [PATCH] Fix nimIoselector define in std/selectors (#25104) Also added some documentation to the header. See: https://forum.nim-lang.org/t/13311 > I did try using the flag, but couldn't get it to work. If I do -d:nimIoSelector, the defined check passes, but the other code fails to compile because there is no const named nimIoSelector. It seemed like a bug to me, do you have a working number compiler invocation? Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> --- lib/pure/selectors.nim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/pure/selectors.nim b/lib/pure/selectors.nim index f4ea498880..9391c391ca 100644 --- a/lib/pure/selectors.nim +++ b/lib/pure/selectors.nim @@ -25,6 +25,10 @@ ## Solaris (files, sockets, handles and user events). ## Android (files, sockets, handles and user events). ## +## By default, the implementation is chosen based on the target +## platform; you can pass `-d:nimIoselector=value` to override it. +## Accepted values are "epoll", "kqueue", "poll", and "select". +## ## TODO: `/dev/poll`, `event ports` and filesystem events. import std/nativesockets @@ -342,7 +346,9 @@ else: res = int(fdLim.rlim_cur) - 1 res - when defined(nimIoselector): + const nimIoselector {.strdefine.} = "" + + when nimIoselector != "": when nimIoselector == "epoll": include ioselects/ioselectors_epoll elif nimIoselector == "kqueue":