I'm beginning to try to port some of my existing C code over to Swift (you have no idea how excited that makes me). Unfortunately, I've hit a stumbling block.
When interacting with some of the system/hardware interfaces in Linux it sometimes (often?) becomes necessary to interact with I/O Control (ioctl). This introduces two complexities that at least appear to me as needing resolution. The first is C macros. A lot ioctl interfaces use headers which define macros that are specific ioctl request operations. These macros typically take the form of `_IO`, `_IOR` or `_IOW` (there are more but this should give you a picture). These values are typically bound to a specific kernel version and thus are subject to change. I point that out because obviously one could just calculate the value and hard-code it into the Swift source (which is what I plan to do in the short term) but this isn't really a portable solution across kernels. The question is what, if anything, is planned around this? The second is variadic C functions. In my case I went ahead and calculated the result of a C macro and hard coded it into a Swift variable (e.g., `let DMX_SET_BUFFER_SIZE: CUnsignedInt = 28461`). This was so I could send it to an ioctl call (e.g., `ioctl(fileReference!, DMX_SET_BUFFER_SIZE, DVBDVR.DVR_BUFFER_SIZE)`). Unfortunately, this died in the compiler with `error: 'ioctl' is unavailable: Variadic function is unavailable`. The interesting part of the compiler error was this though `SwiftGlibc.ioctl:2:13: note: 'ioctl' has been explicitly marked unavailable here`. This seems to imply that it _could_ be on and it just isn't. I searched around a bit and found a few PRs [1] [2] [3] that seem to indicate that Swift does support variadic C functions. Is there a reason why ioctl is not? Sorry if this has been asked or addressed before but I'm at a loss as to how to search these mailing lists. [1] https://github.com/apple/swift/pull/196 [2] https://github.com/apple/swift/pull/413 [3] https://github.com/apple/swift-evolution/pull/38 _______________________________________________ swift-dev mailing list swift-dev@swift.org https://lists.swift.org/mailman/listinfo/swift-dev