Skip to content
Discussion options

You must be logged in to vote

You can usually just replicate the structure definition in Codon:

@tuple
class Pair:
    a: i32
    b: i32

Then you can use Ptr[Pair]:

LIB = "libmylib2.so"
from C import LIB.new_pair(i32, i32) -> Ptr[Pair] as new_pair  # note that C `int` == Codon `i32`

p = new_pair(i32(3), i32(4))
print(p[0].a)  # reads the 'a' field -- use int(..) to convert i32 to standard int

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by qinwf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants