In that instance, I think it's because TIntArray is not a record type (it's essentially a smart pointer) and so RECORDMIN doesn't apply to it.  I do agree though that having an 'align' attribute of some kind will make life a lot easier since you don't have to play around with multiple preprocessor directives that are very hard to get correct.

Gareth aka. Kit

On 21/04/2020 09:29, denisgolovan wrote:
 From tests/test/cg/tvectorcall1.pp

{$PUSH}
{$CODEALIGN RECORDMIN=16}
{$PACKRECORDS C}
type
TM128 = record
case Byte of
0: (M128_F32: array[0..3] of Single);
1: (M128_F64: array[0..1] of Double);
end;
{$POP}

(This declaration mimics how __m128 is defined in Microsoft Visual C++)

Gareth aka. Kit
And even this solution does not support dynamic arrays with scalars, right?

{$PUSH}
{$CODEALIGN RECORDMIN=32}
{$PACKRECORDS C}
type
    TIntArray = array of Integer;
    {$POP}

var v:TIntArray;

begin
    SetLength(v,100);
    Writeln(NativeInt(Pointer(v)) and 31); // writes 16 instead of 0
end.


-- Regards,
Denis Golovan


--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to