[swift-users] Suggested way to get access to unavailable c functions?

Joel Saltzman joelsaltzman at icloud.com
Thu Jan 28 13:22:42 CST 2016

I have some c functions that I would like to import into a CROSS PLATFORM compatible Swift package. It’s only a function from each of these files (fcntl.h, unistd.h, sys/socket.h, netinet/in.h).

Is there a recommended way to do this? 

I was thinking of something like:
Create my wrapper functions:
int swift_fcntl(int fildes, int cmd, int arg){
    return fcntl(fildes, cmd, arg);
int swift_close(int fd){
    return close(fd);
uint16_t swift_htons(uint16_t portNum){
    return htons(portNum);

Use a build script to build the library and copy it /usr/local/lib and /usr/local/include
Use the module map file to import the static lib

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160128/7b3e8607/attachment.html>

More information about the swift-users mailing list