Well, it was a stupid question. You can use the struct
like this.
require 'fiddle/import'
StudentCollegeDetail = Fiddle::Importer::struct [
'int college_id',
'char college_name[50]'
]
The documentation is at this.
As commented by Holger, the Fiddle::Importer
is designed to be used as an argument of the extend()
inside a module like this.
require 'fiddle/import'
module Libc
extend Fiddle::Importer
dlload 'libc.so.6'
typealias 'clockid_t', 'int'
typealias 'time_t', 'int64_t'
Timespec = struct [
'time_t tv_sec',
'long tv_nsec',
]
extern 'int clock_getres(clockid_t clk_id, struct timespec *res);'
end
res = Libc::Timespec.malloc
Libc.clock_getres(Process::CLOCK_REALTIME, res)
p res.tv_nsec