title: 'withUnsafeBytes' is deprecated warning when passing void* argument to c function in swift 5
body: <p>I have a library parsing FIT file in swift using an externally provided c library. The parsing function takes as argument a <code>void * data</code>.
  To call the function, I was converting the data using <code>data.withUnsafeBytes( { (ptr: UnsafePointer&lt;UInt8&gt;) in ...}</code> to build the argument to the c function and it was working fine. </p>
  
  <p>After the upgrade of Xcode to swift 5, I now get a deprecated warning </p>
  
  <p>'withUnsafeBytes' is deprecated: use <code>withUnsafeBytes&lt;R&gt;(_: (UnsafeRawBufferPointer) throws -&gt; R) rethrows -&gt; R</code> instead</p>
  
  <p>I couldn't work out how to fix the code to remove the deprecated warning. The code has been working fine and without warning in swift 4</p>
  
  <p>I tried to change the argument in the closure to take <code>UnsafeRawBufferPointer</code> instead of the UnsafePointer but this resulted in an error in calling the function: <code>Cannot convert 'UnsafeRawBufferPointer' to expected argument type 'UnsafeRawPointer?'</code></p>
  
  <p>This is a small swift file to show the problem:</p>
  
  <pre class="lang-swift prettyprint-override"><code>import Foundation
  
  // Create sample data (Typically would be read from a file
  let data = Data(repeating: 1, count: 10)
  
  data.withUnsafeBytes( { (ptr : UnsafePointer&lt;UInt8&gt;) in
      // call the c function with the void* argument
      let value = readFITfile(ptr)
      print( value )
  })
  </code></pre>
  
  <p>And an example c function</p>
  
  <pre class="lang-c prettyprint-override"><code>unsigned readFITfile(const void * data){
      //Silly example to show it works, just returning the value of pointer as int
      //Typically would parse the data and return a structure
      return (unsigned)data;
  }
  </code></pre>
  
  <p>I saved a small repo with the above code here <a href="https://github.com/roznet/swift2c" rel="noreferrer">https://github.com/roznet/swift2c</a> and the full scale project with the parsing of the file is here <a href="https://github.com/roznet/fit-sdk-swift" rel="noreferrer">https://github.com/roznet/fit-sdk-swift</a></p>