[swift-users] C vararg: Swift Package Manager and System Modules

Daniel Eggert danieleggert at me.com
Thu Dec 17 15:47:25 CST 2015


If I need access to the C fcntl(2):

  int fcntl(int, int, ...)

can I get the swift-package-manager or swift-build-tool to compile C code that wraps this into a non-vararg version:

  int SocketHelper_fcntl_setFlags(int const fildes, int const flags)
  {
    return fcntl(fildes, F_SETFL, flags);
  }
  
  int SocketHelper_fcntl_getFlags(int const fildes)
  {
    return fcntl(fildes, F_GETFL);
  }

?

The “System Modules” approach from <https://github.com/apple/swift-package-manager/blob/master/Documentation/SystemModules.md> doesn’t really work. I’d have to create a .a file and put it into a /usr/lib/SocketHelper.so and /usr/include/SocketHelper.h -- which doesn’t make much sense for something this specific and trivial.

Should I look into libffi for this particular case?

/Daniel



More information about the swift-users mailing list