【发布时间】:2015-06-08 10:21:10
【问题描述】:
我正在尝试从 Swift 调用 C 函数,但我不知道如何定义变量以传递参数。
函数c是:
DBFGetFieldInfo( DBFHandle psDBF, int iField, char * pszFieldName, int * pnWidth, int * pnDecimals );
主要问题是pszFieldName、pnWidth和pnDecimals inout参数。我试过了:
var dbf:DBFHandle = DBFOpen(pszPath, "rb")
var fName:[CChar] = []
var fieldWidth:Int32 = 0
let fieldDecimals:Int32 = 0
let fieldInfo:DBFFieldType = DBFGetFieldInfo(dbf, i, fName, &fieldWidth, &fieldDecimals)
但它给了我一个错误
Cannot invoke 'DBFGetFieldInfo' with an argument list of type '(DBFHandle, Int32, [CChar], inout Int32, inout Int32)'
Expected an argument list of type '(DBFHandle, Int32, UnsafeMutablePointer<Int8>, UnsafeMutablePointer<Int32>, UnsafeMutablePointer<Int32>)'
有什么想法吗?
【问题讨论】:
标签: ios objective-c c swift pointers