  * C code.  This is because we modify a copy of the structure 
  * populated by the C code.
  */
-let OneWayCallback : my_cb_t = {( p : UnsafeMutablePointer<Void> )->Void in
+let OneWayCallback : my_cb_t = {( p : UnsafeMutableRawPointer? )->Void in
     print( "In OneWayCallback(), received a void pointer. " );
-    var _apiS : APIStruct = (UnsafeMutablePointer<APIStruct>(p)).memory
+    // Could have used unsafeBitCast() here
+    guard var _apiS = p?.assumingMemoryBound(to: APIStruct.self).pointee else {
+        print("Could not dereference APIStruct pointer.")
+        return
+    }
     printAPI ( _apiS );
-    print( "Setting m_Long in the structure to 98765432109 " )
+    print( "Setting m_Long in the structure to 98765432109" )
     _apiS.m_Long = 98765432109
 }
 

 * Dumps an instance of the C API's structure, APIStruct, imported via
 * the bridging header.  
 */
func printAPI( s : APIStruct )
{
    print( "Printing APIStruct: " )
    print( "  m_Long: \(s.m_Long)" )
    print( "  m_Array: \(s.m_Array.0) \(s.m_Array.1) \(s.m_Array.2) " )
}

    }
    
    var m_Int : Int32 {
        get { return m_Pointer.pointee.m_Int }
        set( val ) { m_Pointer.pointee.m_Int = val }
    }
    var m_Long : Int64 {
        get { return m_Pointer.pointee.m_Long }
        set( val ) { m_Pointer.pointee.m_Long = val }
    }
    var m_Array : (Int16, Int16, Int16)
    {
        get { return (m_Pointer.pointee.m_Array.0,
                        m_Pointer.pointee.m_Array.1,
            m_Pointer.pointee.m_Array.2) }
        set ( val ) {
            m_Pointer.pointee.m_Array.0 = val.0
            m_Pointer.pointee.m_Array.1 = val.1
            m_Pointer.pointee.m_Array.2 = val.2
        }
    }
}

/**
 * Dumps an instance of WrapperStruct.
 */
func printWrapper( _ s : WrapperStruct )
{
    print( "Printing APIStruct: " )
    print( "  m_Int: \(s.m_Int)" )
    print( "  m_Long: \(s.m_Long)" )
    print( "  m_Array: \(s.m_Array.0) \(s.m_Array.1) \(s.m_Array.2) " )
}

/**
 * A callback implementation that converts the argument to
 * UnsafeMutablePointer<APIStrunct> and wraps that in a WrapperStruct. 
 * Please note that changes made via the WrapperStruct properties
 * are visible to the C code!
 *
 * Notice that here we use a top-level Swift function instead of a closure
 * literal. We could have used
 * a literal as well.
 */
func TwoWayCallback( _ p : UnsafeMutableRawPointer? )->Void
{
    print( "In TwoWayCallback(), received a void pointer. " );
    if let ptr = p?.assumingMemoryBound(to: APIStruct.self) {
        var _wS : WrapperStruct = WrapperStruct(_p: ptr)
        printWrapper( _wS )
        print( "Setting m_Long in the structure to 98765432109 " )
        _wS.m_Long = 98765432109
        print( "Setting the array to 111, 222, 333" )
        _wS.m_Array.0 = 111
        _wS.m_Array.1 = 222
        _wS.m_Array.2 = 333
    }
    else { print("APIStruct pointer is nil.") }
}

print("")
/**
 * Call C code with our more sophisticated 2-way callback.
 */
CUseCallback( TwoWayCallback , 1 )
