<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><pre>First off thanks for the help.</pre><div> </div>
<div>No doubt I'm doing something wrong. I wish I could help debug my own problem but I don't really get what @_silgen_name does. That seems like black magic to me.<br></div>
<div> </div>
<div>That compiled though now it won't link. I've put the code up as a <a href="https://gist.github.com/anonymous/4861aba2280251fe57c6">Gist here</a>.<br></div>
<div> </div>
<div><code>$ swift build
Linking Executable: .build/debug/CastableLive
/home/ryan/Source/castable-live/.build/debug/CastableLive.o/main.swift.o: In function `_TFC12CastableLive6DVBDVRcfT7adapterSi6numberSi_GSqS0__':
/home/ryan/Source/castable-live/main.swift:40: undefined reference to `ioctl'
/usr/bin/ld: /home/ryan/Source/castable-live/.build/debug/CastableLive: hidden symbol `ioctl' isn't defined
/usr/bin/ld: final link failed: Bad value
clang-3.7: error: linker command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: build had 1 command failures
error: exit(1): ["/usr/bin/swift-build-tool", "-f", "/home/ryan/Source/castable-live/.build/debug/CastableLive.o/llbuild.yaml"]</code><br></div>
<div> </div>
<div>On Tue, Jan 5, 2016, at 04:57 PM, Kate Stone wrote:<br></div>
<blockquote type="cite"><div><blockquote type="cite"><div>On Jan 5, 2016, at 12:32 PM, Ryan Lovelett via swift-dev <<a href="mailto:swift-dev@swift.org">swift-dev@swift.org</a>> wrote:<br></div>
<div> </div>
<div><div><div>Just to be clear though the intent of my question was not to quibble<br></div>
<div>with compiler error messages. My real question is how are we meant to do<br></div>
<div>systems programming with Swift on Linux if we cannot call ioctl?<br></div>
</div>
</div>
</blockquote></div>
<div>In the absence of an automatic mechanism for importing the definition of variadic functions you can still define your own prototypes and bind them to the system implementation. For example, this declaration:<br></div>
<div> </div>
<div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;"><span style="">@_silgen_name("ioctl") func ioctl(fildes: CInt, request: UInt64, result: UnsafePointer<Int>) -> Int</span><br></div>
<div> </div>
</div>
<div>… gives you a non-variadic interface to ioctl that you can use for invocations that conform to this specific convention. You can define as many overloads as you wish, and so long as you’re cautious about which one you’re using for a given request you should be able to make progress.<br></div>
<div> </div>
<div><div>The same basic strategy can be applied to any variadic functional interfaces. Ideally you’d want to hide this implementation detail behind a more Swift-friendly API where the request type is implied to create a more type-safe interface.<br></div>
<div><div> </div>
<div><span class="colour" style="color:rgb(66, 66, 66)"><span class="font" style="font-family:'Lucida Grande'"><span class="size" style="font-size:x-small">Kate Stone</span></span></span><span class="font" style="font-family:'Lucida Grande'"><span class="size" style="font-size:x-small"></span></span><span class="colour" style="color:rgb(0, 145, 147)"><span class="font" style="font-family:'Lucida Grande'"><span class="size" style="font-size:x-small"><a href="mailto:k8stone@apple.com">k8stone@apple.com</a></span></span></span><br></div>
<div><div><div style="word-wrap:break-word;-webkit-line-break:after-white-space;"><div style="word-wrap:break-word;-webkit-line-break:after-white-space;"><div style="word-wrap:break-word;-webkit-line-break:after-white-space;"><div style="word-wrap:break-word;-webkit-line-break:after-white-space;"><div style="font-family:LucidaGrande;word-wrap:break-word;-webkit-line-break:after-white-space;"><div style="font-family:Times;word-wrap:break-word;-webkit-line-break:after-white-space;"><span class="font" style="font-family:'Lucida Grande'"><span class="size" style="font-size:x-small"><span class="colour" style="color:rgb(0, 145, 147)"></span> Xcode <span class="colour" style="color:rgb(66, 66, 66)">Low Level Tools</span></span></span><br></div>
<div> </div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote><div> </div>
</body>
</html>