forum-msg-id-135282-edit

Original date:2020-12-17 21:19:09 Edited by: irv Subject: Re: Phix+EuGTK

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. Will keep digging.

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu