Say I have a C function
long double foo(long double *array, size_t n) {
// do something
}
How to call this function from Raku?
In rakudo specific types, there is mention of
Raku | C type |
---|---|
long | long in C |
longlong | longlong in C |
ulong | long and unsigned in C |
ulonglong | longlong and unsigned in C |
size_t | size_t and unsigned in C |
ssize_t | size_t in C |
bool | bool in C |
So I thought if long double
can be mapped as long num64
, which was not the case.
The raku design docs (synopsis 09) call for a num128 type. Afaict this is not yet implemented in rakudo.
The implication is:
Edit: per the comment, here is a worked example of how to write a stub that coerces double to/from long double (for ubuntu):
First write your stub file and put in eg. sqrt_double.c:
Then compile it to a SO:
It will appear in a file like 'libsqrt_double.so'
Then write your raku with Nativecall:
Note that the is native trait will automatically generate the .so filename according to the rules of your OS.