I'm trying to pass the bytes contained within a Data?
to a C function. The C function is declared like:
void func(const void *buffer);
And my Swift looks like:
myData?.withUnsafeBytes { (buffer: UnsafeRawPointer) in
func(buffer)
}
However, this results in an error:
Cannot convert value of type '()' to closure result type '_'
If I change UnsafeRawPointer
to UnsafePointer<Void>
, then the code builds, but I get a warning:
UnsafePointer<Void> has been replaced by UnsafeRawPointer
What is the right way to fix this?