Re: sdl2 and ffi

new topic     » goto parent     » topic index » view thread      » older message » newer message
ChrisB said...

I've just recloned the repository, and it's wiped all the changes and test files I made on my local folder. Ho hum, back to the drawing board.

Oh no! Here's nice guide from the R community on how to avoid that: Basically you use git stash to save your changes then git pull to pull updates then git stash pop to put back your changes.

ChrisB said...

I see that define_c_type returns an atom, which I imagine is a pointer to the block of memory allocated for the structure. The structure may need to be filled to be sent, or may be filled by the C function, but on the eu side the function still need to recieve pointers (atoms) to send to the C function of the block of memory allocated.

This is correct. The value returned from define_c_type() are pointers to ffi_type structures. When using std/ffi.e the values of C_INT, C_POINTER, etc. are also pointers. The only difference being the built-in values from std/ffi.e are pulled directly from libffi using define_c_var().

The crucial point being that you still need to allocate memory and then peek/poke values accordingly. Not only should you avoid passing the values you made with define_c_type() to c_func(), but doing so could overwrite the memory at that location which could cause any number of weird problems later.


new topic     » goto parent     » topic index » view thread      » older message » newer message


Quick Links

User menu

Not signed in.

Misc Menu