long double math.h functions appear to not be exported in swift. I don’t know 
why.

This horrible hack works:

// in f80.h
extern void sqrt_f80( void *result, const void *v );
extern void pow_f80( void *result, const void *v, const void *e );
...

// in f80.c
void sqrt_f80( void *result, const void *v )    { *(long double *)result = 
sqrtl( *(const long double *)v ); }
void pow_f80( void *result, const void *v, const void *e )      { *(long double 
*)result = powl( *(const long double *)v,*(const long double *)e ); }
…

// in f80.swift
func sqrt( _ a:Float80 ) -> Float80             { var result = Float80(); var v 
= a; sqrt_f80( &result, &v ); return result; }
func pow( _ a:Float80,_ e:Float80 ) -> Float80 { var result = Float80(); var v1 
= a; var v2 = e; pow_f80( &result, &v1, &v2 ); return result; }
…

Sorry for my bad english.


> Il giorno 05 lug 2016, alle ore 19:44, Jeff Kelley via swift-users 
> <swift-users@swift.org <mailto:swift-users@swift.org>> ha scritto:
> 
> Hello all,
> 
>       I’m using Xcode 8.0 and Swift 3 on OS X 10.11, and I’m trying to use 
> powl in an OS X Playground. I see the definition of the pow-related functions 
> in math.h here:
> 
> extern float powf(float, float);
> extern double pow(double, double);
> extern long double powl(long double, long double);
> 
> But the Swift-imported version at Darwin.C.math looks like this:
> 
> public func powf(_: Float, _: Float) -> Float
> public func pow(_: Double, _: Double) -> Double
> 
> Where did powl go?
> 
> 
> Jeff Kelley
> 
> slauncha...@gmail.com <mailto:slauncha...@gmail.com> | @SlaunchaMan 
> <https://twitter.com/SlaunchaMan> | jeffkelley.org <http://jeffkelley.org/>
> _______________________________________________
> swift-users mailing list
> swift-users@swift.org <mailto:swift-users@swift.org>
> https://lists.swift.org/mailman/listinfo/swift-users


_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to