[Gambas-user] external functions and structs

Benoît Minisini g4mba5 at gmail.com
Thu Nov 29 16:54:12 CET 2018


Le 29/11/2018 à 16:36, gen braga a écrit :
> Yes, i spent the last few hours debugging the lib's sources with gdb and 
> everything was ok inside it. I saw the problem you pointed only within 
> gambas debugger.
> 
> The point is, the array/  "char bits[SIXBIT_LEN]"///inside sixbit 
> structure is filled by a pointer with some characters, from the second 
> string parameter passed to the method called inside Gambas.
> 
> The array looks Ok from position 8 on. Position 0 to 7 receive garbage 
> from the argument's previous characters. As you said, misalignment issues...
> 
> I'm not very experienced in this matter but will try to tweak the lib's 
> sources. Do you have any suggestion?
> 
> Thanks in advance,
> 

Every datatype must be aligned to a multiple of its size. A char can be 
anywhere, a 32 bits integer must be at a byte index multiple of 4, a 64 
bits integer at a byte index multiple of 8, a pointer at a multiple of 4 
or 8 depending if your CPU is 32 bits or 64 bits, and so on.

-- 
Benoît Minisini


More information about the User mailing list