Unmapped Types

From RAD Studio
Jump to: navigation, search

Go Up to Support for Delphi Data Types and Language Concepts


6-byte Real types

The old Delphi 6-byte floating-point format is now called Real48.

The old Real type is now a double. C++ does not have a counterpart for the Real48 type. Consequently, you should not use Delphi code that includes this type with C++ code. If you do, the header file generator will generate a warning.

Arrays as return types of functions

In Delphi, a function can take as an argument -- or return as a type -- an array. For example, the syntax for a function GetLine returning an array of 80 characters is:

type 
  Line_Data = array [0..79] of char;
function  GetLine: Line_Data;

C++Builder introduces the StaticArray structure. You can declare the same function as follows:

StaticArray<char, 80>GetLine();

The C++ language specification does not permit arrays as return types (nor as arguments). One workaround is to encapsulate an array in a structure or class and use that structure or class as a return type or as an argument type. Such a structure is already defined in the RAD Studio libraries: see StaticArray. This is the C++Builder counterpart of the Delphi static array built-in type. The type and number of elements of a StaticArray variable must be specified as template parameters.

Note: Passing large arrays by value from one function or procedure to another can affect the performance. You should consider passing arrays by reference (or pointer).

Note: Array properties, which are also valid in Delphi, are not a problem in C++ because the Get method takes an index value as a parameter, and the Set method returns an object of the type contained by the array. See Creating Array Properties.