newlisp import atof

Q&A's, tips, howto's
Locked
dexter
Posts: 74
Joined: Fri Nov 11, 2011 12:55 am

newlisp import atof

Post by dexter »

in my osx

Code: Select all

Darwin DingDangs-MacBook.local 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64
I ran the code from docs

Code: Select all

> (import "libc.dylib" "atof" "double" "char*")
atof@9BB16FC3
> (atof "3.141")
-1682161784
what is -1682161784 ?
I thought it will be 3.141,am I right?

my newlisp is 10.4.4

Anyone can help a little?

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: newlisp import atof

Post by Lutz »

works fine:

Code: Select all

newLISP v.10.4.4 on OSX IPv4/6 UTF-8 libffi, execute 'newlisp -h' for more info.

> (import "libc.dylib" "atof" "double" "char*")
atof@952074D8
> (atof "3.141")
3.141
> 
Looks like you are using a newLISP version not compiled for extended ffi using libffi. On the Mac use the official version from the binary distribution (currently at 10.4.5), which is compiled for libffi or, when you compile yourself, use a make file with "ffi" in the name like: makefile_darwin_utf8_ffi. Other versions can only use the simple ffi which doesn't handle floats.

dexter
Posts: 74
Joined: Fri Nov 11, 2011 12:55 am

Re: newlisp import atof

Post by dexter »

yeah
it works

Because I always make newlisp on some mobile devices

SO I removed the dependces libs as less as I can

thanks

Locked