Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Viewing all articles
Browse latest Browse all 4650

Declaring char array in Ruby FFI

$
0
0

I have the following C code:

typedef void (*mycallback) (char buf[128]);void take_callback(mycallback cb){}

I've written the equivalent Ruby FFI declarations as below (following advice for structs on FFI wiki):

  callback :mycallback, [[:char, 128]], :void  attach_function :take_callback, [:mycallback], :void

When I run it, I get the following error:

`find_type': unable to resolve type '[:char, 128]' (TypeError)

It seems I'm not declaring the char array in the callback correctly. From the way arrays work in function arguments in C, I think I should use :pointer instead of [:char, 128] . But I'm not sure about the peculiarities of FFI. What's really the correct syntax here?


Viewing all articles
Browse latest Browse all 4650

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>