'inout Data' is not convertible to 'Data'


(Rick M) #1

I could swear this was compiling a couple days ago, as I was making the call inside the block and dealing with issues around that.

Can anyone explain what's going on here?

class
MyClass
{
    func
    execute()
    {
        self.dataBuffer = Data(capacity: lgsImageDataSize)
        
        self.dataBuffer?.withUnsafeMutableBytes
        ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
        error: 'inout Data' is not convertible to 'Data'

        { (inBuffer) -> Void in
            some_call(inBuffer)
            debugLog("some_call() called")
        }
    }
    
    var dataBuffer: Data?
}

some_call() is a C function that looks like this:

  some_result* some_call(void* data);

The generated interface in Xcode looks like:

  public func some_call(_ data: UnsafeMutableRawPointer!) -> OpaquePointer!

I tried commenting out the call to some_call(), but I still get the error.

···

--
Rick Mann
rmann@latencyzero.com


(Rick M) #2

Oh wow, it's the debugLog() call! If that's inside the block, it fails to compile.

···

On Apr 24, 2017, at 14:18 , Rick Mann via swift-users <swift-users@swift.org> wrote:

I could swear this was compiling a couple days ago, as I was making the call inside the block and dealing with issues around that.

Can anyone explain what's going on here?

class
MyClass
{
   func
   execute()
   {
       self.dataBuffer = Data(capacity: lgsImageDataSize)

       self.dataBuffer?.withUnsafeMutableBytes
       ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
       error: 'inout Data' is not convertible to 'Data'

       { (inBuffer) -> Void in
           some_call(inBuffer)
           debugLog("some_call() called")
       }
   }

   var dataBuffer: Data?
}

some_call() is a C function that looks like this:

  some_result* some_call(void* data);

The generated interface in Xcode looks like:

  public func some_call(_ data: UnsafeMutableRawPointer!) -> OpaquePointer!

I tried commenting out the call to some_call(), but I still get the error.

--
Rick Mann
rmann@latencyzero.com

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

--
Rick Mann
rmann@latencyzero.com