alien icon indicating copy to clipboard operation
alien copied to clipboard

returning struct from function (not pointer) - how to ?

Open UffeJakobsen opened this issue 10 years ago • 2 comments

Hi,

I'm doing af alien ffi wrapper for some library. The library have a nasty habit of returning structs - like this:

struct version_info { int major; int minor; int micro; };

struct version_info some_library_get_version(void) { struct version_info ver;

ver.major = MAJOR_VERSION;
ver.minor = MINOR_VERSION;
ver.micro = MICRO_VERSION;

return ver;

}

How do I represent this through lua/alien ?

Thanks in advance

/Uffe

UffeJakobsen avatar Jul 06 '14 21:07 UffeJakobsen

Hi Uffe,

Alien does not support this directly, but a workaround might be possible. What is the architecture (CPU and OS)?

Fabio Mascarenhas

On Sun, Jul 6, 2014 at 6:13 PM, Uffe Jakobsen [email protected] wrote:

Hi,

I'm doing af alien ffi wrapper for some library. The library have a nasty habit of returning structs - like this:

struct version_info { int major; int minor; int micro; };

struct version_info some_library_get_version(void) { struct version_info ver;

ver.major = MAJOR_VERSION; ver.minor = MINOR_VERSION; ver.micro = MICRO_VERSION;

return ver;

}

How do I represent this through lua/alien ?

Thanks in advance

/Uffe

— Reply to this email directly or view it on GitHub https://github.com/mascarenhas/alien/issues/42.

mascarenhas avatar Jul 07 '14 19:07 mascarenhas

Hi Fabio, Thanks for your fast reply. I'm targeting FreeBSD/Linux 64bit (amd64) /Uffe

UffeJakobsen avatar Jul 07 '14 21:07 UffeJakobsen