[swift-users] Importing empty C structs
Rick Mann
rmann at latencyzero.com
Mon Apr 17 20:19:25 CDT 2017
I'm trying to make a module out of a C library and header file. It has at least one empty struct:
struct lgs_context_t {};
and a function:
LGS_EXPORT struct lgs_context_t* lgs_init(const lgs_context_params_t* params);
Swift sees the function, I can call it and assign the result to a variable, but Xcode (as usual) fails to show me what it thinks the type is. So I can't declare a class member to hold the returned pointer.
I'm trying to declare the member like this:
var ctx: lgs_context_t? // Use of undeclared type 'lgs_context_t'
I finally tried calling it like this:
let ctx: UnsafeMutablePointer = lgs_init(...)
and the resulting error message gave me OpaquePointer. But couldn't it just typealias lgs_context_t to OpaquePointer?
Is there any way to do this in the modulemap?
Thanks!
--
Rick Mann
rmann at latencyzero.com
More information about the swift-users
mailing list