newlisp import atof

Started by dexter, December 25, 2012, 08:58:50 PM

Previous topic - Next topic

dexter

in my osx



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



> (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

#1
works fine:


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

#2
yeah

it works



Because I always make newlisp on some mobile devices



SO I removed the dependces libs as less as I can



thanks