libffcall
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Libffcall] calling __std call function that return a structure


From: Bruno Haible
Subject: Re: [Libffcall] calling __std call function that return a structure
Date: Thu, 14 Mar 2019 19:31:30 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-141-generic; KDE/5.18.0; x86_64; ; )

Hello Volodymir,

> I am struggling to understand if the libffcall supports calling the a 
> c-function following from a DLL when the function has the following signature
> 
> struct MyResultStructWithPODMembers
> {
> int r1;
> bool r2;
> float r3;
> double r4;
> };
> 
> MyResultStructWithPODMembers __stdcall 
> the_API_function(MyinputStructWithPODMembers i_input_by_val);
> 
> ?
> 
> So that the input and the outputs are structures passed/returned by val.

Three notes:

1) Structs that contain 'float' or 'double' members have special
argument-passing conventions in some ABIs. GNU libffcall does not support
these cases. (In some cases, it even cannot support it with the current
API.) Therefore, if you have structs that contain 'float' or 'double' members,
better pass them by pointer, and let libffcall pass and return pointers
instead.

2) Functions that pass C++ structs or classes by value are not supported
by GNU libffcall. You need to have functions that pass these by value;
then you can access these functions through libffcall.

3) __stdcall support has not been tested in a long time. I believe it works
on x86. On x86_64, __stdcall is a no-op. On arm, __stdcall has never been
tested.

Bruno

[1] https://docs.microsoft.com/en-us/cpp/cpp/stdcall




reply via email to

[Prev in Thread] Current Thread [Next in Thread]