Re: Phix+EuGTK
- Posted by irv Dec 17, 2020
- 2242 views
For testing purposes, I created a shared library in C:
/* libmytest */ #include <stdio.h> double hello(double x) { printf("Hello! Your number was %g\n",x); return x*2.0; }Euphoria:
include std/dll.e atom mylib = open_dll("libmytest.so") atom fn = define_c_func(mylib,"hello",{C_DOUBLE},C_DOUBLE) printf(1,"Got back: %g\n", c_func(fn,{123.456}))
Can anybody explain why I get two hello's?
$ eui eulibtest.ex Hello! Your number was 123.456 Hello! Your number was 123.456 Got back: 246.912Phix:
atom mylib = open_dll("libmytest.so") atom fn = define_c_func(mylib,"hello",{C_DOUBLE},C_DOUBLE) printf(1,"Got back: %g\n", c_func(fn,{123.456}))
$ p plibtest.ex Hello! Your number was 123.456 Got back: 246.912I appears that passing doubles to and from C libraries does work in Phix, and works twice as hard in Euphoria. The problem lies elsewhere in my program. Will keep digging.