__declspec(delphirecord)

From Appmethod Topics
Jump to: navigation, search

Go Up to Keywords, Alphabetical Listing Index


Category

Modifiers, Keyword Extensions, Storage Class Specifiers

Syntax

__declspec( delphirecord ) declarator

The delphirecord storage class attribute is used when converting Object Pascal records into C++ classes/structs in .hpp headers (using dcc32 -JPHNE <filename.pas>). In Object Pascal there is a convention regarding records being returned from functions, which states that a function returning a record will return a hidden parameter pointing to the record to be returned. Object Pascal returns a pointer to a location that is zero initialized, whereas C++ does not offer such a guarantee. For compliance, when C++ finds a struct that is being returned from a function and is flagged as __declspec(delphirecord), it will zero out the memory location.

Note: There is one particular case when a user may want to declare a struct __declspec(delphirecord) explicitly: for a record originally declared in Object Pascal that has either the {$EXTERNALSYM} or the {$NODEFINE} directive.

See also