William Xu wrote:

[...]
Hm, this seems hiding the error. Now, my_pi is 0.0, [...]

Hello,

well, of course my_pi is zero in your code, because you never set its value to anything else than its default initializer, which is zero in almost any sensible C compiler.

You write

    (foreign-declare "
    double my_pi;
    ")

    (foreign-parse "
    double my_pi = 3.14;
    ")

which means "Include 'double my_pi;' verbatim in the C code, parse 'double my_pi = 3.14' as a C declaration and generate Scheme bindings for it". The parser of easyffi discards the initializer, because it is none of its business to deal with it. That would be the job of the C compiler, but the C compiler never gets to see the constant 3.14.

You should either write

    (foreign-parse "
    double my_pi;
    ")

    (foreign-declare "
    double my_pi = 3.14;
    ")

or simply

    (foreign-parse/declare "
    double my_pi = 3.14;
    ")

to achieve the desired effect.

cu,
Thomas


_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to