Subject:
Re: [ruby-ffi] Cast null to an undeclared struct when calling a function
From:
Alvaro
Date:
12/29/10 10:45 AM
To:
ruby-ffi@googlegroups.com

2010/12/28 Wayne Meissner <wmeissner@gmail.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)
>

Thanks!, that works.


-- Alvaro