I was recently trying out compiling swift on windows, and I found that Glibc was not something that could be imported, or at least not without some extra doing. I was trying to use the sleep() function that glibc provides.
My question is simple: how can I import glibc, or something equivalent?
Glibc is not available on windows as it wraps the system library of the same name. The system libc on windows, at least for modern cases, is ucrt. However, the windows C library does not provide a sleep function. The closest thing would be Sleep from the Windows SDK. This has differences in semantics that it limits you to 10ms granularity. This would be available through the WinSDK module as it is part of the SDK. The other option would be to use Foundation which provides Thread.sleep(forTimeInterval:). For a longer term solution, I think that this would be a great thing to add to the new System package.
Some CRT functions seems missing like _kbhit(). I used _kbhit() frequently and to access the function I must manually add the missing conio.h in ucrt.modulemap on each Swift Windows release.
Please Swift Windows team add conio.h to ucrt.modulemap in the current Swift Windows distrib.