Using Glibc in Windows

Hi everyone,

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.

Terms of Service

Privacy Policy

Cookie Policy