I know that it is not sudden, sorry for the clickbait title, but I couldn't describe it in another way. I found some changes in the compiler related to unions back in September, but I still do not know what to do.
Firstly, I got a compile-time failure: '__Anonymous_field0' is unavailable: refer to the members of the anonymous type instead, meanwhile all other platforms (Darwin, Glibc, Musl) were still able to compile fine without any changes.
public extension sigaction {
#if canImport(Darwin)
typealias Union = __sigaction_u
#elseif canImport(Glibc)
typealias Union = __Unnamed_union___sigaction_handler
#elseif canImport(Musl)
typealias Union = __Unnamed_union___sa_handler
#elseif canImport(Bionic) && _pointerBitWidth(_32)
typealias Union = __Unnamed_union___Anonymous_field0
#else
typealias Union = __Unnamed_union___Anonymous_field1
#endif
var handler: Union {
get {
#if canImport(Darwin)
__sigaction_u
#elseif canImport(Glibc)
__sigaction_handler
#elseif canImport(Musl)
__sa_handler
#elseif canImport(Bionic) && _pointerBitWidth(_32)
__Anonymous_field0
#elseif canImport(Bionic)
__Anonymous_field1
#endif
}
set {
#if canImport(Darwin)
__sigaction_u = newValue
#elseif canImport(Glibc)
__sigaction_handler = newValue
#elseif canImport(Musl)
__sa_handler = newValue
#elseif canImport(Bionic) && _pointerBitWidth(_32)
__Anonymous_field0 = newValue
#elseif canImport(Bionic)
__Anonymous_field1 = newValue
#endif
}
}
}
Secondly, I commented out all the code that failed during compilation and got a crash while trying to understand what had even gone wrong. I tried to print the sigaction structure and got a runtime crash this time:
let structure = sigaction()
String(describing: structure) //crash
Mirror(reflecting: structure) //crash