Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to use C variadic functions with the latest Swift 3 snapshot?

One example of this is ioctl

error: 'ioctl' is unavailable: Variadic function is unavailable

Darwin.ioctl:2:13: note: 'ioctl' has been explicitly marked unavailable here
public func ioctl(_: Int32, _: UInt, _ varargs: Swift.Any...) -> Int32

When it was imported from C, it appears to be properly marked as accepting varargs.

Is this the case?

Why would it be marked explicitly unavailable? Doesn't Swift 3.0 add support for this?

like image 772
ahyattdev Avatar asked Oct 30 '22 01:10

ahyattdev


1 Answers

The only way to get around this is to create a wrapper function in C that is not variadic. However, an effort is underway to create wrappers for the functions in Darwin that need it, and recently multiple were added for ioctl by this commit.

To use the wrapper, you need to have a swift version at least as new as the June 22nd snapshot. Make sure you are using that toolchain.

like image 162
ahyattdev Avatar answered Dec 03 '22 15:12

ahyattdev