[Gambas-user] Distribution of custom shared libraries

Benoît Minisini g4mba5 at gmail.com
Sat Feb 23 00:23:00 CET 2019


Le 22/02/2019 à 20:26, Cedron Dawg a écrit :
> Thanks.  That's okay.  I am trying to do things properly.
> 
> I was able to define a PPA and am now on version 3.12.2.
> 
> Notes about that:
> 
> I was using the GTK2.  When I upgraded, the Form_Keypress event failed to fire.  I switched to QT4, and it now works fine.  This problem is reproducible with a simple test program.

This has been fixed in commit 
https://gitlab.com/gambas/gambas/commit/aa66e9bcd5f10719428d77014fda3c6df2093f26.

> 
> I have a Struct defined in my code to share with the shared library.
> 
> Public Struct InfoBlock
>      AxisCount As Integer
>      ButtonCount As Integer
>      DriverVersion As Integer
>      Filler As Integer
>      GamepadName[128] As Byte
> End Struct
> 
> typedef struct
> {
>      int     AxisCount;
>      int     ButtonCount;
>      int     DriverVersion;
>      int     Filler;
>      char    GamepadName[128];
> } InfoBlock;
> 
> 
> In the 3.1.1 version, the Filler was not there.  When I upgraded, I needed to add the Filler to make the alignment correct.  I know you mention in the docs that this is a tricky issue, so this is meant to be informative, I'm not looking for any kind of resolution.

Without your full source code, I can't tell you. It's just that a 
structure may be aligned differently by the C compiler, whereas Gambas 
has a deterministic algorithm for that. And the result may not be the 
same as soon as there are holes or unaligned fields in your structure.

AFAIK, there is no norm for structure implementation in C: the compiler 
can reorder the fields and add memory holes as it wants, changing its 
mind between 32 bits / 64 bits and between versions.

So it's almost impossible for an interpreter to deal with that in all 
cases. :-(

-- 
Benoît Minisini


More information about the User mailing list