<div dir="ltr">Hi folks,<div><br></div><div>I ran into this issue (or at least surprise) trying to compile some code that uses math.h functions on both OSX and Linux. Here's an example:</div><div><div><br></div><div>#if os(Linux)</div><div> import Glibc</div><div>#else</div><div> import Darwin</div><div>#endif</div><div><br></div><div>let x = Float(1.2345)</div><div>let y = sin(x)</div><div>print(y)</div></div><div><br></div><div>Compiles and runs fine on OSX, but fails with the following error on Linux:</div><div><div><b>MathTest.swift:8:13: error: cannot convert value of type 'Float' to expected argument type 'Double'</b></div></div><div><br></div><div>I think I tracked this down to the fact that Darwin includes the additional <a href="https://github.com/apple/swift/blob/master/stdlib/public/SDK/Darwin/tgmath.swift.gyb#L44">tgmath style macros</a> that provide the overloaded sin(x: <span class="s2">Float</span>) -> <span class="s2">Float swift function. Glibc only includes plain math.h functions:</span></div><div><span class="s2"><div>double sin(double x);<br></div><div>float sinf(float x);</div><div><br></div><div>I can, of course, just use the explicit *f math.h functions on both platforms. But I'm curious if this is a bug I should file or if this is intentional to not have overloaded math functions in Swift. I couldn't find much mention of it in the bug tracker.</div><div><br></div><div>Tim</div></span></div>
</div>