Hi swift-users, (sorry for the cross post to swift-dev, but wasn't sure where it belongs)
I tried to find guarantees about the memory layout Swift tuples but couldn't find anything. The reason I ask is because I'd like to use them as fixed sized (stack allocated) arrays. I'm pretty sure they're actually not guaranteed to be stack allocated but highly likely I assume :). Am I correct in assuming that let swift_events: (kevent, kevent) = ... has the same memory layout as struct kevent c_events[2] = ... ? In other words, is this legal: var events = (kevent(), kevent()) withUnsafeMutableBytes(of: &events) { event_ptr in precondition(MemoryLayout<kevent>.size * 2 == event_ptr.count) if let ptr = event_ptr.baseAddress?.bindMemory(to: kevent.self, capacity: 2) { return kevent(someFileDescriptor, ptr, 2, ptr, 2, nil) } } I'm assuming yes but I'd like to make sure. Many thanks, Johannes _______________________________________________ swift-dev mailing list swift-dev@swift.org https://lists.swift.org/mailman/listinfo/swift-dev