I realized i already asked this question and Matthew Flatt had responded like this, for anyone wondering:
--- I see that there's not a good way right now, but here's a workaround that uses information about the current layout: A cpointer value is implemented as a Chez Scheme record with either 1 field or 2 fields. There are 2 fields only when the cpointer has an offset as a result of `ptr-add`, so you can probably ignore that. To extract the first field, assume that a record has the same layout as a vector, so use `Svector_ref(p, 0)` to extra the field from the cpointer `p`. Then you can use `Sunsigned_value()` to convert that field value to a pointer-sized integer, then case. I might have some part of that wrong, but it should be close... Of course, there should be better support for record-field access and cpointer extraction, so I'll add to the API. --- Nate On Mon, Oct 5, 2020 at 3:59 AM Nate Griswold <[email protected]> wrote: > I have a temporary workaround where i have created an ffi function > racket-side to call into c, so that i can automatically use the _cptr's > racket-to-c function. I wonder if there is a way to manually extract the c > value for the case where i want it in a return value of racket_apply. > > Nate > > > On Mon, Oct 5, 2020 at 3:26 AM Nate Griswold <[email protected]> > wrote: > >> Note this is from a return value of racket_apply; i called a racket >> function from c code and want to store the cptr it has returned. >> >> Nate >> >> >> On Mon, Oct 5, 2020 at 3:25 AM Nate Griswold <[email protected]> >> wrote: >> >>> What is the best way to access a value that is a cpointer from c code? >>> Should i convert it to an integer? I have been looking at this for a while, >>> about an hour, and will continue to look but just thought the list might be >>> able to answer faster. I know there are chez functions to convert `ptr`s to >>> integers but those aren't working for me (not an integer error). >>> >>> Nate >>> >> -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/CAM-xLPr9dZkz3FkWs_oh-jtcR7bgsuhSgYfTvKHFrCPaqo6GLQ%40mail.gmail.com.

