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
SlaunchaMan@gmail.com | @SlaunchaMan <https://twitter.com/SlaunchaMan> | jeffkelley.org <http://jeffkelley.org/>
Loooop
(Antonino)
2
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
SlaunchaMan@gmail.com <mailto:SlaunchaMan@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
It seems like Swift has broken a lot of the export functionality. Some of
the exporting system was actually a bug but resulting in useful
functionality (i.e like importing C Macros as enums). But once fixed we
lost a lot of it.
···
*___________________________________*
*James⎥Head of Trolls*
*james@supmenow.com <james@supmenow.com>⎥supmenow.com <http://supmenow.com>*
*Sup*
*Runway East *
*10 Finsbury Square*
*London*
* EC2A 1AF *
On 6 July 2016 at 07:23, Antonino Ficarra via swift-users < swift-users@swift.org> wrote:
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> 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
SlaunchaMan@gmail.com | @SlaunchaMan <https://twitter.com/SlaunchaMan> |
jeffkelley.org
_______________________________________________
swift-users mailing list
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