Is there a way to point Ruby FFI to a header file instead of writing attach_function calls? A header file basically has the same exact information.
temp_convert.rb:
attach_function :temp_convert, [:float], :float
temp_convert.h:
float temp_convert(float temp);
Because C header files are written in C but Ruby interpreters only interpret Ruby. Also, the header files might not even be available at runtime.
There has been talk about automatically generating
attach_functioncalls from headers. However, as I hinted at above, this basically means that you must implement a full C compiler (well, the full front half of one, to be precise). At the moment, the Ruby implementers are more focused on making Ruby run as fast as C to alleviate the need to use FFI in the first place than writing their own C compiler (which is a non-trivial undertaking even though you only need to do the lexing, parsing, semantic analysis and typing parts, not the actual code generation or optimization).