On Wed, Aug 19, 2015 at 10:09 AM, Maarten Koopmans
<
maarten....@gmail.com> wrote:
>
>
> Op woensdag 19 augustus 2015 heeft Ian Lance Taylor <
ia...@golang.org> het
> volgende geschreven:
>>
>> On Wed, Aug 19, 2015 at 7:05 AM, Maarten Koopmans
>> <
maarten....@gmail.com> wrote:
>> >
>> > Pffff. I have a really hard time returning a struct that holds the
>> > buffer
>> > and the length.
>>
>> What problems are you having?
>>
>> > Given the above playground, is there a way to retrun structs from Go ->
>> > C?
>>
>> Here is an example:
http://play.golang.org/p/irjBR5o0kj .
>
>
> That's not quite what I need. I want to call a function with parameters via
> libffi, and then get multiple values back. E.g. pass in byte array pointer,
> length. Get back processed byte array with length.
Can you describe the problem you are having?
The Go code is going to have to have a struct definition, and that
struct ought to be defined in the C preamble. You can't create that
using libffi--that doesn't make sense, since the Go code has to return
a type declared in Go, whether via cgo or not. What you can do on the
libffi side is define a struct type and define the function as
returning that struct type. You can do that using the usual libffi
calls.
Where along this path are you running into trouble?
Ian