Static array parameter

Top  Previous  Next

What is translated > Types > Arrays > 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();


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





is translated to:


C++Builder                                                                Other                                                                                                                                                                                                                                                                                                                      


void __fastcall Foo(const Char* Arr, int Arr_maxidx)      void Foo(const std::vector<Char> Arr)                                                                                                                                                                                                                                                                                      

{                                                                               {                                                                                                                                                                                                                                                                                                                          

}                                                                               }                                                                                                                                                                                                                                                                                                                          


void __fastcall bar()                                                    void bar()                                                                                                                                                                                                                                                                                                                 

{                                                                               {                                                                                                                                                                                                                                                                                                                          

  Char chararray[10/*# range 1..10*/];                             Char chararray[10/*# range 1..10*/];                                                                                                                                                                                                                                                                                     

  Foo(OpenArrayEx<Char>(chararray, 10), 9);                                                                                                                                                                                                                                                                                                                                          

}                                                                                 std::vector<Char> test__0(chararray, chararray + 10 - 1 + 1);                                                                                                                                                                                                                                                            






This page belongs to the Delphi2Cpp Documentation

Delphi2Cpp home  Content