Static array parameter

Top  Previous  Next

What is translated > Array parameters > Static array parameter

 

A static array is passed to functions as an open array parameter. The additional second parameter for the upper bound of the array is inserted into the declaration of the function automatically and is passed to the function automatically too. The upper bound of the array is calculated by means of a macro:

 

#define MAXIDX(x) (sizeof(x)/sizeof(x[0]))-1

 

 

procedure foo(Arr: Array of Char);

 

procedure bar();

var

   chararray : Array [1..10] of Char;

begin

    foo(chararray);

end;

 

is translated to:

 

void foo( const char* Arr, int Arr_maxidx );

 

void bar( )

{

  char chararray [ 10 ];

  foo( chararray, MAXIDX( chararray ) );

}

 

 

 



This page belongs to the Delphi2Cpp Documentation

Delphi2Cpp home  Content