[fpc-pascal] Dynamic arrays in FP

Peter Vreman peter at freepascal.org
Thu May 5 13:16:52 CEST 2005


At 13:05 5-5-2005, you wrote:

>On 05 May 2005, at 13:06, Michael Van Canneyt wrote:
>
>>>>Dynamic arrays are an internal type of pascal. C doesn't know dynamic
>>>>arrays. That it works with delphi is pure luck.
>>>
>>>Sorry, but pascal dynamic arrays are just pointers.
>>
>>Totally wrong. They are a reference counted type.
>
>Yes, but aren't they "just" C-style arrays (i.e. pointers) in the same way 
>that ansistrings are "just" pchars?

It is also calling convention related how C expects arrays to be pushed. 
 From the example:

// extern "C"  __cdecl __declspec(dllexport) int get_array(double a[], 
double b[], int size, double val);

Here the array is expected on the stack on some i386 targets. Using 'double 
*a' is less ambigious, because it then always needs to be a pointer.


Peter





More information about the fpc-pascal mailing list