Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2008-10

Dynamic Array Type

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Den Jean

Hi,

I would like to export (cdecl) SetLength like this

procedure SetArrayLength(var DynArr: DynArrayType; NewLen: Integer); cdecl; export;
begin
  SetLength(DynArr, NewLen);
end;

but the type DynArrayType is not know,
though it is used in the definition of the function

./rtl/inc/system.fpd:Function Length(A : DynArrayType) : Integer;

Is it an internal compiler type ?

Is it possible what I try to do. (cfr writeln)
Probably not, but you never know if you don't ask.

I would like to resize pascal dynamic arrays from c-code and would like to avoid to have to define an exported function for every dyn array type (element size).

regards,

Den Jean

Reply by email

Jonas Maebe
to Den Jean
Den Jean wrote 12 lines
I would like to export (cdecl) SetLength like this procedure SetArrayLength(var DynArr: DynArrayType; NewLen: Integer); cdecl; export; begin SetLength(DynArr, NewLen); end; but the type DynArrayType is not know, though it is used in the definition of the function ./rtl/inc/system.fpd:Function Length(A : DynArrayType) : Integer;

There is no such definition in the system unit. The above is probably some fake definition in a documentation file.

Is it an internal compiler type ?

There simply is no such type (not in the compiler, nor in the rtl). Length() on the other hand is handled internally by the compiler.

I would like to resize pascal dynamic arrays from c-code and would like to avoid to have to define an exported function for every dyn array type (element size).

The function to get the length of a dynamic array is private to the compiler. While hacks are currently possible that would allow you to declare only one such function and always use that, there is no guarantee that these would keep working in the future.

Jonas

Reply by email