Pass C double to Eu shared library
- Posted by Jerome May 11, 2012
- 1558 views
I have a shared library made with EU 4 that I would like to access from C by passing an array of doubles. Looking through the manual I found this:
Euphoria shared dynamically loading library can also be used by C programs as long as only 31-bit integer values are exchanged. If a 32-bit pointer or integer must be passed, and you have the source to the C program, you could pass the value in two separate 16-bit integer arguments (upper 16 bits and lower 16 bits), and then combine the values in the Euphoria routine into the desired 32-bit atom.
Is there a clean way to do this?
My current code is essentially the following:
-- Eu Code export function MyFunc(sequence x) ? x end function
// C Code extern MyFunc(double x[]) int main() { double x[4] = {1.1,2.2,3.3,4.4}; MyFunc(x); return 0; }
Thanks,
Ira