Subject:
Re: [ruby-ffi] Cast null to an undeclared struct when calling a function
From:
Wayne Meissner
Date:
12/28/10 6:20 PM
To:
ruby-ffi@googlegroups.com

On 29 December 2010 06:56, Alvaro <zevarito@gmail.com> wrote:
> Hi,
>
> I have this scenario:
>
>    UserInfo *user_info = CloneUserInfo((UserInfo *) NULL);
>
>    DoSomethingWithUserInfo(user_info)
>
> I wonder to know if is possible to cast to UserInfo without having to
> declare the struct from ruby side since I am actually not going to use


Just declare the function as taking a :pointer parameter, then pass
nil as the argument
e.g.
module Foo
  attach_function :CloneUserInfo, [ :pointer ], :pointer
  attach_function :DoSomethingWithUserInfo, [ :pointer ], :void
end

user_info = Foo.CloneUserInfo(nil)
Foo.DoSomethingWithUserInfo(user_info)