Unmapped Types

From Appmethod Topics
Jump to: navigation, search

Go Up to Language Support for the Appmethod Libraries (C++)

6-byte Real types

The old Object Pascal 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 Object Pascal 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 Object Pascal, 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;

Appmethod C++ 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 Appmethod libraries: see StaticArray. This is the Appmethod C++ counterpart of the Object Pascal 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 Object Pascal, 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.

See Also