[fpc-devel] Dynamic Array Type
Jonas Maebe
jonas.maebe at elis.ugent.be
Thu Oct 30 22:53:26 CET 2008
On 30 Oct 2008, at 20:54, Den Jean wrote:
> 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
More information about the fpc-devel
mailing list