Subject:
[ruby-ffi] Re: Basic question about types
From:
Wayne Meissner
Date:
10/20/09 6:16 PM
To:
ruby-ffi@googlegroups.com


You can use typedef in much the same way
e.g.
module Foo
  include FFI::Library
  if some_situation
    typedef :uint, :some_type
  else
    typedef :short, :some_type
  end
  attach_function :some_function, [ :some_type ], :void
end


You just have to figure out how to infer what some_situation is in
ruby land, since FFI does not support the C pre-processor.  If it is
the cpu or OS architecture, either rbconfig, or FFI::Platform might be
helpful.


2009/10/20 Gimi <liang.gimi@gmail.com>:
>
> Hi all,
>
> I'm new to FFI, and I have a basic question about types. Assume there
> is some C code like this:
> # -- C code begin --
> #if some situation
> typedef sometype unsignedint
> #else
> typedef sometype int
> #endif
>
> void some_function(sometype);
> #-- C code end --
>
> So I mean when the types of parameters of a function are different in
> different situations, how do I write the Ruby code?
>
> Any help will be greatly appreciated.
>
> Regards,
>