-
Notifications
You must be signed in to change notification settings - Fork 50
importing C libraries #235
Comments
Hi @rutlang, basically the following:
|
Thanks @arshajii. Follow up question: if the imported C functions require pointer arguments, how does one provide the addresses of Seq variables (different types, including strings, tuples (for structs), lists (for arrays?), and perhaps even ints) in the function call? |
You can use So e.g. # double foo(struct { bool, int64 } *x)
from C import foo(Ptr[Tuple[bool, int]]) -> float
x = (True, 42)
y = foo(__ptr__(x)) For strings, you can use |
Is this the recommended way to handle the case where the variable is an int in C and i32 in Seq?
|
Yes that's right. You can also create the pointer directly: p = Ptr[i32](5) # similar to malloc(5 * sizeof(int)) in C
p[0] = ...
p[1] = ... # etc. |
Thanks @arshajii. How to import from_ptr()? |
There is an |
How are functions from third-party or user C libraries imported when the arguments include structs or enums?
The text was updated successfully, but these errors were encountered: