rubyffiruby-ffi

FFI - Attach function with argument type FILE?


How would I wrap a function that accepts an argument of type FILE using FFI in Ruby?

int fprintf ( FILE * stream, const char * format, ... );

Solution

  • It's not type FILE, but FILE *. Just another :pointer like any other.

    If you need to build a struct to examine the contents of the memory pointed to, you need to find the definition of FILE in your system's stdio.h and reproduce it as an FFI struct.