Any help on correct syntax in Swift to access a “t

2019-07-19 06:45发布

I have compiled and imported a dylib C Library called portaudio (PortAudio website) into an Xcode 6.1 Swift project, all the functions / types are accessible except for one which is

typedef void PaStream;

I am having trouble understanding how to use that in Swift, in C I declare it like:

PaStream *audioStream = NULL;

Can anybody help on the Swift equivalent as I get a warning saying undeclared Type / unresolved identifier, it looks like Swift can not bridge a typedef void xyz; ?

Many thanks for any help.

1条回答
何必那么认真
2楼-- · 2019-07-19 07:27

The C typedef

typedef void PaStream;

is indeed not imported to Swift because you can't define a variable of type void. Even in C, you would only define pointer variables of type PaStream *.

Therefore you could add

typedef PaStream *PaStreamPtr;

to the bridging header file and then use it as

var audioStream : PaStreamPtr = nil
查看更多
登录 后发表回答