3 ms·
Unrelated, but is this a common practice in Swift? #if os(Linux) import Glibc #else import Darwin.C #endif Feels a bit nasty.
by nodesocket 11y ago
Unrelated, but is this a common practice in Swift?
#if os(Linux)
import Glibc
#else
import Darwin.C
#endif
Feels a bit nasty.
- huydotnet 11y agoYeah, I grabbed this lines from Apple document https://swift.org/package-manager/#example-usage https://swift.org/package-manager/#example-usage
- trymas 11y agoAFAIK, at least for now it is. Libraries on Linux and OS X just are different. Maybe when core libraries [0] will be fully finished we could just use `import Foundation` on both platforms. [0] https://swift.org/core-libraries/ https://swift.org/core-libraries/
- nly 11y agoAre a bunch of #ifdef's in C any less nasty?
- edgyswingset 11y agoI would imagine it to be a fact of life for library developers.