The problem is that struct g722_dstate
is an "incomplete type",
and Swift cannot import variables of an incomplete type, only variables
which are pointers to an incomplete type (and those are imported
as OpaquePointer
).
Adding the complete struct definition to the imported header file would
be the easiest solution.
If that is not possible then one workaround would be to add
#import "g722_codec.h"
static struct g722_dstate * __nonnull dstatePtr = &dstate;
to the bridging header file, which defines a variable containing the
address of the "opaque" dstate
variable. This is imported to Swift as
var dstatePtr: OpaquePointer
and can then be used e.g. as
g722_coder_init(dstatePtr)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…