[fpc-pascal] Questions regarding arrays
Honza
befelemepeseveze at gmail.com
Thu Sep 23 09:50:18 CEST 2010
2010/9/23 Graeme Geldenhuys <graemeg.lists at gmail.com>:
> Out of interest. Do you know if dynamic array elements are in sequence
> (storage area in memory) too - like static arrays? So could I do the
> same as above, but instead of using a static array, use a dynamic
> array, and pass the address of the first element to the C API?
AFAIK yes as long as you don't break (it's possible using some wild
casting) the ref counting mechanism and handle the zero length case.
var
V1: array [L..H] of T;
V2: array of T;
magic_c_function(@V1[L]);
if Length(V2) <> 0 then
magic_c_function(@V2[0])
else
magic_c_function(nil);
--
bflm
freepascal-bits.blogspot.com
More information about the fpc-pascal
mailing list