Re: Phix+EuGTK

new topic     » goto parent     » topic index » view thread      » older message » newer message

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.912 
Phix:

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.912 
I 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.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu